android开发大作业开发记录(关于制作底部导航栏)

            利用Radio Group和Radio button来制作底部导航栏

1.效果如图所示

2.首先,给账本和图图表两个图标设置转换切换

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
    android:drawable="@drawable/table_checked"></item>
    <item android:drawable="@drawable/table_unchecked"></item>
</selector>

另外一个和他相似。

3.在style中设置RadioButton的样式

 <style name="TableMenuItem">
        <item name="android:layout_width">0dp</item>
        <item name="android:layout_height">match_parent</item>
        <item name="android:layout_weight">1</item>
        <item name="android:drawablePadding">3dp</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:textSize">14dp</item>

    </style>

4.在xml文件中直接使用

<LinearLayout
        android:layout_below="@id/money_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginTop="280dp">
        <!--导航栏上方灰色的线条-->
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/grey" />

        <RadioGroup
            android:id="@+id/main_rgroupTabMenu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/main_rbtnCount"
                style="@style/TableMenuItem"
                android:layout_marginTop="10dp"
                android:button="@null"
                android:checked="true"
                android:drawableTop="@drawable/table_count_channel"
                android:text="账本" />

            <RadioButton
                android:id="@+id/main_rbtnAdd"
                style="@style/TableMenuAdd"
                android:button="@null"
                android:drawableTop="@drawable/add" />

            <RadioButton
                android:id="@+id/main_rbtnTable"
                android:layout_marginTop="10dp"
                style="@style/TableMenuItem"
                android:button="@null"
                android:drawableTop="@drawable/table_channel"
                android:text="图表" />

        </RadioGroup>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/grey" />

仅供参考= =

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值