开发工具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. AltiumDesigner 常用快捷键小结

    Ctrl + o  |  打开文件夹/文档 Ctrl + p  |  打印设置 Esc   |  从当前步骤退出 Shift +鼠标滚轮  |  向左/向右移动 Ctrl + C (或 Ctrl + ...

  2. fabric 持久化

    每个容器都有目录需要映射出来.在volume中添加如下映射即可: peer是: /var/hyperledger/peer{number}/org{number}:/var/hyperledger/p ...

  3. springcloud ConfigServer的工作原理

    前话 根据前文得知,bootstrapContext引入了PropertySourceLocator接口供外部源加载配置,但作用是应用于子级ApplicationContext的环境变量Environ ...

  4. [leetcode]77. Combinations组合

    Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: I ...

  5. 6E - 寒冰王座

    不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前. 死亡骑士:"我要买道具!" ...

  6. 19. pt-query-digest

    慢查询参数 slow_query_log=1slow_query_log_file=/mysql3306/log/slow.log 记录的是查询语句,而非管理语句.除非启用 los_slow_admi ...

  7. CentOS6.5在虚拟机中安装

    只有一点,先建虚拟机,再选择iso镜像安装,注意,安装路径不能有中文空格之类的. CentOS6.5 64位下载链接 链接:https://pan.baidu.com/s/1d6zp5LtKtkL8I ...

  8. Android 软件管理工具类Utils

    Android 软件管理工具类Utils /** * Created by uilubo on 2015/9/30. * 工具类 */ public class Utils { public stat ...

  9. 牛客练习赛31 B 赞迪卡之声妮莎与奥札奇 逻辑,博弈 B

    牛客练习赛31 B 赞迪卡之声妮莎与奥札奇 https://ac.nowcoder.com/acm/contest/218/B 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 2621 ...

  10. python模块:configparser

    """Configuration file parser. A configuration file consists of sections, lead by a &q ...