简单的程序底部Tab例子
16lz
2021-01-24
1.建立Tab的简单例子:
2.java代码段:
3.另外附上部分图片资源,个人觉得做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() {@Overridepublic 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只要资源有就可以做的很好
更多相关文章
- java.lang.IllegalStateException Fragment already added: Home
- Android(安卓)8/9高通平台客制化虚拟导航按键隐藏
- Android(安卓)针对View的截图操作
- Android(安卓)数据库升级 数据迁移 数据不丢失
- 蓝牙最简单的例子,最难得的简单
- layui 上传图片 移动端 调用相机
- android 代码控制LinearLayout 宽度高度 报错widget.LinearLayou
- android 在Resources 中定义arrays
- Android(安卓)WebView 加载富文本内容