底部导航栏

来源:互联网 发布:绿联mac网线usb驱动 编辑:程序博客网 时间:2024/05/29 14:27
//文字颜色
<selector xmlns:android="http://schemas.android.com/apk/res/android">    <item android:state_checked="true" android:color="#3F51B5"/>    <item android:state_checked="false" android:color="#8f8f8f"/></selector>

//替换图片@drawable/shou

<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:state_checked="false" android:drawable="@drawable/syb"/>未选中状态    <item android:state_checked="true" android:drawable="@drawable/syh"/>选中状态    <item android:drawable="@drawable/syb"/>默认状态</selector>

//底部导航栏
<RadioGroup            android:id="@+id/rg"            android:paddingTop="5dp"            android:background="#f4f5f6"             android:gravity="center"            android:layout_width="match_parent"            android:layout_height="40dp"            android:orientation="horizontal"            android:layout_alignParentBottom="true"            android:layout_centerHorizontal="true">             <RadioButton            android:id="@+id/rb"            android:gravity="center"            android:button="@null"            android:drawableTop="@drawable/shou"            android:layout_width="0dp"            android:layout_weight="1"            android:layout_height="match_parent"            android:textColor="@drawable/selector_tab_color"          />        <RadioButton            android:id="@+id/rb1"            android:gravity="center"            android:button="@null"            android:drawableTop="@drawable/wei"            android:layout_width="0dp"            android:layout_weight="1"            android:layout_height="match_parent"            android:textColor="@drawable/selector_tab_color"          />        <RadioButton            android:id="@+id/rb2"            android:gravity="center"            android:button="@null"            android:drawableTop="@drawable/deng"            android:layout_width="0dp"            android:layout_weight="1"            android:layout_height="match_parent"            android:textColor="@drawable/selector_tab_color"            />        </RadioGroup>
//将RadioButton添加进数组
int[] rid={R.id.rb,R.id.rb1,R.id.rb2};
RadioGroup rg= (RadioGroup) findViewById(R.id.rg);
for(int j=0;j<rid.length;j++){ RadioButton rb= (RadioButton) findViewById(rid[j]);}

 
原创粉丝点击