here is code main class
public class TabSample extends TabActivity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setTabs();
}
private void setTabs() {
addTab("Wechat", R.drawable.tab_home, ShowList.class);
addTab("Social", R.drawable.tab_search, UploadVideo.class);
addTab("Contact Us", R.drawable.tab_home, Contactus.class);
addTab("Setting", R.drawable.tab_search, DoNotDo.class);
}
private void addTab(String labelId, int drawableId, Class<?> c) {
TabHost tabHost = getTabHost();
Intent intent = new Intent(this, c);
TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(
R.layout.tab_indicator, getTabWidget(), false);
TextView title = (TextView) tabIndicator.findViewById(R.id.title);
title.setText(labelId);
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
icon.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
}
}
here is xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:background="#ffffff"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_weight="0" />
</LinearLayout>
</TabHost>
조각 TabHost 사용 http://envyandroid.com/archives/326/align-tabhost-at-bottom 나는이 사용됩니다 위챗 무엇인지 잘 모릅니다 –
을하지만, 확실히 당신은 사용하여 동일한 결과를 얻을 수 있습니다 "Tabhost". –
모든 ImageButton에 대해 하나의 RelativeLayout을 수평으로 정렬하고 'RelativeLayout'에 대한 배경색을 설정할 수도 있습니다. – Xcihnegn