zoukankan      html  css  js  c++  java
  • [Android]--RadioGroup+RadioButton实现底部导航栏

    RadioGroup+RadioButton组合方式打造简单实用的底部导航栏

    代码块:

    <?xml version="1.0" encoding="utf-8"?>
        <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
        <FrameLayout
            android:id="@+id/fl_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@id/rg_content">
    
        </FrameLayout>
    
        <RadioGroup
            android:paddingTop="@dimen/dp_10"
            android:id="@+id/rg_content"
            android:layout_width="match_parent"
            android:layout_height="@dimen/dp_60"
            android:layout_alignParentBottom="true"
            android:background="@color/white"
            android:orientation="horizontal">
    
            <RadioButton
                android:textColor="@drawable/tv_color_selected"
                android:textSize="@dimen/dp_12"
                android:text="首页"
                android:button="@null"
                android:gravity="center_horizontal"
                android:drawableTop="@drawable/ic_home_selected"
                android:id="@+id/rb_home"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"/>
    
            <RadioButton
                android:gravity="center_horizontal"
                android:textColor="@drawable/tv_color_selected"
                android:textSize="@dimen/dp_12"
                android:text="产品"
                android:button="@null"
                android:drawableTop="@drawable/ic_loan_selected"
                android:id="@+id/rb_money"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"/>
    
            <RadioButton
                android:gravity="center_horizontal"
                android:textColor="@drawable/tv_color_selected"
                android:textSize="@dimen/dp_12"
                android:text="个人"
                android:button="@null"
                android:drawableTop="@drawable/ic_me_selected"
                android:id="@+id/rb_mine"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"/>
        </RadioGroup>
    
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_above="@+id/rg_content"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="@dimen/dp_60"
            android:background="@color/line_background"></View>
    </RelativeLayout>
    
    
    
     

    效果图片:

  • 相关阅读:
    var、let、const
    面向女朋友自我介绍
    ES6——class
    一个错误引发的——对异步回调与for循环(小白错误,大神勿进)
    关于this
    关于作用域
    HTML5 8
    HTML5 7
    HTML5 6
    HTML5 4
  • 原文地址:https://www.cnblogs.com/geekformore/p/10497491.html
Copyright © 2011-2022 走看看