其他分享
首页 > 其他分享> > android底部菜单栏的编写

android底部菜单栏的编写

作者:互联网

  开发工具android stdio,组件Radio Button

  1.新建空项目DDDD

  2.将事先准备好的图标复制到对应的文件夹中(如图),这五个文件夹都要拷进去,图标文件http://pan.baidu.com/s/1slVnev7

  3.在values/colors.xml中加入几种会用到的颜色资源

#3F51B5#303F9F#FF4081#f6f7f9#6E7174#4169E1#E1E1E1

  4.在values/styles.xml中为RadioButton编写统一样式

@color/colorPrimary@color/colorPrimaryDark@color/colorAccent" _ue_custom_node_="true">0dpmatch_parent1@nullcenter@drawable/top_menu6dp@color/main_menu_color" _ue_custom_node_="true">

  5.在res/drawable下新建几个RadioButton对应的xml文件,将图片导入






 

6. 编写activity_main.xml文件,并将之前写好的样式和图片资源导入RadioButton,界面部分就此完工,继续加功能的话,就要通过监听器实现活动间的跳转了。

 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="test.example.com.dddd.MainActivity">

    <LinearLayout
        android:gravity="bottom"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <RadioGroup
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="55dp">
            <RadioButton
                style="@style/RadioButtonButtomTab"
                android:drawableTop="@drawable/main_menu_location"
                android:checked="true"
                android:text="定位"
                />
            <RadioButton
                style="@style/RadioButtonButtomTab"
                android:drawableTop="@drawable/main_menu_weather"
                android:text="天气" />
            <RadioButton
                style="@style/RadioButtonButtomTab"
                android:drawableTop="@drawable/main_menu_step"
                android:text="步数"
                />
            <RadioButton
                android:text="好友"
                android:drawableTop="@drawable/main_menu_friends"
                style="@style/RadioButtonButtomTab"/>

  最终效果如图

 

标签:xml,node,color,菜单栏,RadioButton,编写,android,custom
来源: https://blog.51cto.com/u_12870633/2834312