`

简单的程序底部Tab例子

阅读更多
1.建立Tab的简单例子:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="horizontal" android:layout_width="fill_parent"
	android:layout_height="wrap_content">
	<LinearLayout android:orientation="vertical"
		android:layout_width="80px" android:layout_height="wrap_content"
		android:id="@+id/home" android:background="@drawable/tab_one_normal">
		<TextView android:layout_width="wrap_content"
			android:layout_height="wrap_content" android:text="@string/home"
			android:background="@drawable/home" style="@style/SpecialText" />
	</LinearLayout>
	<ImageView android:layout_width="wrap_content"
		android:layout_height="wrap_content" android:src="@drawable/line" />
	<LinearLayout android:orientation="vertical"
		android:layout_width="80px" android:layout_height="wrap_content"
		android:background="@drawable/tab_one_normal" android:id="@+id/publish">
		<TextView android:layout_width="wrap_content"
			android:layout_height="wrap_content" android:text="@string/publish"
			style="@style/SpecialText" android:background="@drawable/publish" />
	</LinearLayout>
	<ImageView android:layout_width="wrap_content"
		android:layout_height="wrap_content" android:src="@drawable/line" />
	<LinearLayout android:orientation="vertical"
		android:layout_width="80px" android:id="@+id/change"
		android:layout_height="wrap_content" android:background="@drawable/tab_one_normal">
		<TextView android:layout_width="wrap_content"
			android:layout_height="wrap_content" android:text="@string/change"
			style="@style/SpecialText" android:background="@drawable/change" />
	</LinearLayout>
	<ImageView android:layout_width="wrap_content"
		android:layout_height="wrap_content" android:src="@drawable/line" />
	<LinearLayout android:orientation="vertical"
		android:layout_width="80px" android:id="@+id/more"
		android:layout_height="wrap_content" android:background="@drawable/tab_one_normal">
		<TextView android:layout_width="wrap_content"
			android:layout_height="wrap_content" android:text="@string/more"
			style="@style/SpecialText" android:background="@drawable/more" />
	</LinearLayout>

</LinearLayout>




2.java代码段:
		linearLayout = (LinearLayout) findViewById(R.id.home);
		linearLayout.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				linearLayout
						.setBackgroundResource(R.drawable.tab_two_highlight);
				publish.setBackgroundResource(R.drawable.tab_one_normal);
				change.setBackgroundResource(R.drawable.tab_one_normal);
				more.setBackgroundResource(R.drawable.tab_one_normal);
			}
		});




3.另外附上部分图片资源,个人觉得做Tab只要资源有就可以做的很好
分享到:
评论
1 楼 lufengdie 2010-09-28  

你真搞笑·

相关推荐

Global site tag (gtag.js) - Google Analytics