您的位置:首页 > 其它

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>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐