tab按下效果,使用LinearLayout + ImageView.和LinearLayout + Button
2014-11-06 10:06
393 查看
tab按下效果时要使用使用LinearLayout + ImageView.
LinearLayout 注意要加 android:clickable="true" 属性,
tab 上小图标用 ImageView(如果用Button的话,点了bottom LinearLayout 就没响应 ,原理其简单。当然button做大点 给按钮做selector 也是一种方式 )
drawable/home_tab_bar_pressed.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/home_tab_bg_pressed" />
<item android:state_focused="true" android:state_pressed="false"
android:drawable="@drawable/home_tab_bg_pressed" />
<item android:drawable="@drawable/home_tab_bar_bg" />
</selector>
<LinearLayout
android:id="@+id/tab_1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/home_tab_bar_pressed"
android:clickable="true"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="7dip"
android:paddingTop="9dip" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_chat_bubble"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="消息"
android:textColor="#666666"
android:textSize="12sp" />
</LinearLayout>
LinearLayout 注意要加 android:clickable="true" 属性,
tab 上小图标用 ImageView(如果用Button的话,点了bottom LinearLayout 就没响应 ,原理其简单。当然button做大点 给按钮做selector 也是一种方式 )
drawable/home_tab_bar_pressed.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/home_tab_bg_pressed" />
<item android:state_focused="true" android:state_pressed="false"
android:drawable="@drawable/home_tab_bg_pressed" />
<item android:drawable="@drawable/home_tab_bar_bg" />
</selector>
<LinearLayout
android:id="@+id/tab_1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/home_tab_bar_pressed"
android:clickable="true"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="7dip"
android:paddingTop="9dip" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_chat_bubble"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="消息"
android:textColor="#666666"
android:textSize="12sp" />
</LinearLayout>
相关文章推荐
- 使用PagerSlidingTabStrip ViewPager SwipeRefreshLayout打造豆瓣App的效果
- 使用DrawerLayout实现侧滑菜单,,RadioButton+Fragment实现页面主布局,首页面使用tabLayout+viewPager实现
- 51.使用HorizontalScrollView+LinearLayout实现文字+图片的自动跑马灯效果
- Android之TabLayout+抽屉式效果和RecyclerView的使用
- android LinearLayout等view如何获取button效果
- 使用TabLayout+ViewPager+Fragment+DataBing实现仿网易新闻主界面效果
- Tablayout和Viewpager的结合使用,实现导航的效果
- DrawerLayout+TabLayout+ViewPager+RadioButton+Fragment+pullToRefresh+ImageLoader
- android SlidingTabLayout实现ViewPager页卡滑动效果
- Android TransitionDrawable ImageView过度效果使用实例
- android中使用selector动态改变imageView或ImageViewButton的背景
- 点击textview 使用selector改变对应viewGroup(LinearLayout,RelativeLayout)的背景
- android 给LinearLayout中添加一定数量的控件,并让着一定数量的控件从右到左移动,每隔若干秒停顿一下,最后一个view链接第一个view,然后继续移动循环往复,形成一个死循环简单动画效果
- Android UI设计之<一>使用ImageView实现ProgressBar旋转效果
- Android 使用LinearLayout.getChildAt(i)获取一个线性布局的view,并实现content中实现方法
- 自定义属性之LinearLayout ImageView TextView模拟图片文字按钮
- Android:使用ImageView和ScaleAnimation实现连续变化的ProgressBar效果
- CheckableLinearLayout 实现一个可选中的layout 以及 CheckableImageView
- ViewPager使用1-ViewPager多页面滑动切换以及动画效果(ViewPager+Layout+PagerAdapter )
- 【Android界面实现】使用PagerSlidingTabStrip实现滑动标签同步的ViewPager效果