RadioGroup 完成功能菜单效果

来源:互联网 发布:linux怎么改文件夹名 编辑:程序博客网 时间:2024/06/06 01:46

这里写图片描述

效果图 如下 :

布局代码:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <LinearLayout        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1"        android:background="#efeaea" >    </LinearLayout>    <RadioGroup        android:id="@+id/rg_init"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginBottom="0dp"        android:background="#F4F5F7"        android:orientation="horizontal" >        <RadioButton            android:id="@+id/rb_home"            style="@style/BottomTapTheme"            android:drawableTop="@drawable/btn_tab_home_selector"            android:text="首页" />        <RadioButton            android:id="@+id/rb_theme"            style="@style/BottomTapTheme"            android:drawableTop="@drawable/btn_tab_theme_selector"            android:text="专题" />        <RadioButton            android:id="@+id/rb_reader"            style="@style/BottomTapTheme"            android:drawableTop="@drawable/btn_tab_reader_selector"            android:text="阅读" />        <RadioButton            android:id="@+id/rb_voice"            style="@style/BottomTapTheme"            android:drawableTop="@drawable/btn_tab_voice_selector"            android:text="视听" />    </RadioGroup></LinearLayout>

样式代码;

  <!-- ContentFragment BottomTap Theme. -->    <style name="BottomTapTheme">        <item name="android:layout_width">wrap_content</item>        <item name="android:layout_height">wrap_content</item>        <item name="android:layout_gravity">center_vertical</item>        <item name="android:button">@null</item>        <item name="android:drawablePadding">3dp</item>        <item name="android:padding">5dp</item>        <item name="android:textColor">@drawable/btn_tab_text_selector</item>        <item name="android:layout_weight">1</item>        <item name="android:gravity">center</item>    </style>

结束了 !

1 0