首页 > 移动平台 > 详细

android底部菜单栏的编写

时间:2021-05-31 12:11:57      阅读:15      评论:0      收藏:0      [点我收藏+]

? 开发工具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"/>

? 最终效果如图

技术分享图片

?

android底部菜单栏的编写

原文:https://blog.51cto.com/u_12870633/2834312

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!