开发工具android stdio,组件Radio Button

1.新建空项目DDDD

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

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

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="main_menu_color">#f6f7f9</color>
<color name="main_menu_color_normal">#6E7174</color>
<color name="main_menu_color_check">#4169E1</color>
<color name="divider_color">#E1E1E1</color>
</resources>

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

<resources>

    <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style> <style name="RadioButtonButtomTab">
<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:button">@null</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@drawable/top_menu</item>
<item name="android:paddingTop">6dp</item>
<item name="android:background">@color/main_menu_color</item>
</style>
</resources>

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

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/friends_selected" android:state_checked="true"/>
<item android:drawable="@mipmap/friends"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/location_selected" android:state_checked="true"/>
<item android:drawable="@mipmap/location"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/step_selected" android:state_checked="true"/>
<item android:drawable="@mipmap/step"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/weather_selected" android:state_checked="true"/>
<item android:drawable="@mipmap/weather"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/main_menu_color_check" android:state_checked="true"/>
<item android:color="@color/main_menu_color_normal"/>
</selector>

6. 编写activity_main.xml文件,并将之前写好的样式和图片资源导入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: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"/>
</RadioGroup>
</LinearLayout>
</RelativeLayout>

最终效果如图

android底部菜单栏的编写的更多相关文章

  1. android 底部菜单栏实现(转)

    1.Android学习之BottomNavigationBar实现Android特色底部导航栏 2.Android底部导航栏的四种实现 3.Android BottomNavigationBar底部导 ...

  2. Android底部菜单栏+顶部菜单

    底部菜单栏+顶部菜单(wechat)demo http://blog.csdn.net/evankaka/article/details/44121457 底部菜单demo http://blog.c ...

  3. 【Android UI设计与开发】5.底部菜单栏(二)使用Fragment实现底部菜单栏

    既然 Fragment 取代了TabActivity,当然 TabActivity 的能实现的菜单栏,Fragment 当然也能实现.主要其实就是通过菜单栏的点击事件切换 Fragment 的显示和隐 ...

  4. 我的Android之路——底部菜单栏的实现

    底部菜单栏的实现 底部菜单栏两种实现方法:ViewPager:可滑动的界面:Fragment:固定的界面. 首先,页面布局,在除去顶部toolbar之后,将主界面分为两部分,一部分为界面显示区,另一部 ...

  5. 【Android开发笔记】底部菜单栏 FragmentTabHost

    公司项目,需求本来是按照谷歌官方指南写的,菜单栏设计成在导航栏下方 结果呢,审评时,BOSS为了和iOS统一,改成了底部菜单栏(标准结局),我只能呵呵呵呵呵呵呵 查了查资料发现实现底部菜单栏用的是Fr ...

  6. 底部菜单栏(二) TabHost & RadioGroup 实现

    需求:使用TabHost & RadioGroup实现底部菜单栏: 效果图: 实现分析: 1.目录结构: 代码实现: 1. activity_main.xml <?xml version ...

  7. 底部菜单栏(一) TabHost实现

    需求:使用TabHost实现底部菜单栏: 效果图: 实现分析: 1.目录结构: 代码实现: 1.activity_main.xml <?xml version="1.0" e ...

  8. FragmentTabHost+FrameLayout实现底部菜单栏

    现在一般的app都使用底部菜单栏,那具体怎么实现的呢!我们就来看看 首先给大家展示一下布局文件 1 <LinearLayout xmlns:android="http://schema ...

  9. Android Camera 相机程序编写

    Android Camera 相机程序编写 要自己写一个相机应用直接使用相机硬件,首先应用需要一个权限设置,在AndroidManifest.xml中加上使用设备相机的权限: <uses-per ...

随机推荐

  1. 20175314 《Java程序设计》第二周学习总结

    20175314 <Java程序设计>第二周学习总结 教材学习内容总结 我在APPstore上发现了一个可以支持我们在IOS系统上学习实践Java程序的开发环境,只需要购买专业版就可以使用 ...

  2. Codeforces Round #497 (Div. 2)

    Codeforces Round #497 (Div. 2) https://codeforces.com/contest/1008 A #include<bits/stdc++.h> u ...

  3. Python开发【第六篇】:面向对象

    configparser模块 configparser用于处理特定格式的文件,其本质是利用open来操作文件. 文件a.txt [section1] k1 = 123 k2:v2   [section ...

  4. Newtonsoft.Json反序列化(Deserialize)出错:Bad JSON escape sequence

    使用Newtonsoft.Json反序列化收到的字串为JObject或其它支持的数据模型,有时错误,提示如下: Bad JSON escape sequence: \c. Path , positio ...

  5. Django的rest_framework的权限组件和频率组件源码分析

    前言: Django的rest_framework一共有三大组件,分别为认证组件:perform_authentication,权限组件:check_permissions,频率组件:check_th ...

  6. java基础 ----- 循环结构

    循环的结构特点 :    循环条件   循环操作 -----     while 循环 来个小例子,实现打印50 份shij 1.确定循环条件和循环操作 2.套用while语法写出代码 3.检查循环能 ...

  7. 648. Replace Words 替换成为原来的单词

    [抄题]: In English, we have a concept called root, which can be followed by some other words to form a ...

  8. 156. Binary Tree Upside Down反转二叉树

    [抄题]: Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left nod ...

  9. 团队项目NABCD分析

    1.卡片分类讨论 我们团队在软件工程课上对准备开发的帮你项目进行激烈的讨论后,得出了两个特点. (1)信息检索 (2)主动推送 之所以得出这两个特点,是因为我们作为学生,平常在校园里面有很多专用群和Q ...

  10. hibernate save数据的时候报错:ids for this class must be manually assigned before calling save()

    这个错误是因为eclipse  这种jpatools 自动生成的实体类内没把id 设置为自增,还有id的值在生成的时候默认为string 即使加上了也所以无法自增 ,所以还需要把string 换成In ...