主页面Frgment横滑+底部导航布局功能(1)

 首先frgment控件

<FrameLayout
    android:id="@+id/frgemt_view"
    android:layout_width="match_parent"
    android:layout_height="0dp"
   android:layout_weight="1"
    >
</FrameLayout>

下一步 RadioGroup里面加

<RadioGroup
    android:id="@+id/radio_group"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:orientation="horizontal"


    >
    <RadioButton
        android:id="@+id/show_1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:button="@null"
        android:text="首页"
        android:checked="true"
        android:gravity="center"
        这两个是新建一个drawable页面 里面写上true和flase 是为了选中和不选中的状态下换颜色
        android:drawableTop="@drawable/scole"
         android:background="@drawable/corl"

        />
    <RadioButton
        android:id="@+id/show_2"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:button="@null"
        android:text="首页"
        android:gravity="center"
       android:drawableTop="@drawable/scole"
        android:background="@drawable/corl"
        />
    <RadioButton
        android:id="@+id/show_3"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:button="@null"
        android:text="首页"
        android:gravity="center"
        android:drawableTop="@drawable/scole"
        android:background="@drawable/corl"
        />
    <RadioButton
        android:id="@+id/show_4"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:button="@null"
        android:text="首页"
        android:gravity="center"
        android:drawableTop="@drawable/scole"
        android:background="@drawable/corl"
        />

</RadioGroup>

选中变颜色代码如下

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item  android:state_checked="true" android:drawable="@color/colorAccent"></item>
<item  android:state_checked="false" android:drawable="@color/colorPrimaryDark"></item>


</selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  24dp颜色跟图标如下 创建的时候在res 第一个文件夹下的drawable右键 new------Vector Asset然后选择下面的那些
  <item  android:drawable="@drawable/ic_arrow_upward_black_24dp"  android:state_checked="true" />
    <item android:drawable="@drawable/ic_arrow_zise_24dp" android:state_checked="false"></item>
</selector>

猜你喜欢

转载自blog.csdn.net/qq_41880256/article/details/81219615