模仿墨迹天气设置界面布局
来源:互联网 发布:数据搜索网站 编辑:程序博客网 时间:2024/05/02 04:48
发现的android 特刊:
【eoe特刊】第二十七期 OpenGL ES学习及项目解析
http://www.eoeandroid.com/thread-240293-1-1.html
eoe 在上海Android大会 :http://club.eoe.cn/index/shmdc
最终效果如下:
具体来说就是实现了checkbox自定义选中和为选择样式,菜单项根据不同位置设置不同背景.
先上整体布局文件代码:
<LinearLayout 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" android:background="#DFE1E0" android:orientation="vertical"> <LinearLayout style="@style/SettingItemTop" android:background="@drawable/setting_list_top" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView style="@style/MySettingText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="开启通知" /> <CheckBox style="@style/MyCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> <LinearLayout style="@style/SettingItemMiddle" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView style="@style/MySettingText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="开启铃声" /> <CheckBox style="@style/MyCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> <LinearLayout style="@style/SettingItemBottom" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView style="@style/MySettingText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="开启震动" /> <CheckBox style="@style/MyCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> </LinearLayout>
注意到:
style="@style/MySettingText"
这一句,这里用了style.xml这个文件来控制样式.Android实际开发中,会有很多时候一些部件的属性是要重复出现的,如果每个控件都要单独的 把这些属性单独的输入一次,那样会很没有效率.可以将重复的代码添加到style.xml中,设置成一种样式,在用到这些属性是引用这个样式即 可.style="@style/MySettingText"这个是设置文字的属性,代码如下:
<style name="MySettingText"> <item name="android:layout_margin">10dp</item> <item name="android:layout_weight">6</item></style>
这里仅用了两个属性.开发中可以根据实际需要自行修改.以后每个设置项的文字不需要再把这些属性再添加一边,引用一下这个style即可.
CheckBox样式自定义用到了selector.
style="@style/MyCheckBox"
此句对应的代码:
<style name="MyCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox"> <item name="android:button">@drawable/check</item> <item name="android:layout_margin">10dp</item> <item name="android:layout_weight">1</item> </style>
注意到此句:
<item name="android:button">@drawable/check</item>
这里就用了selector自定义样式.
在res/drawable下建立一名为check(自定)的xml文件,代码如下:
<?xml version="1.0" encoding="UTF-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:drawable="@drawable/on"/> <item android:state_checked="false" android:drawable="@drawable/off"/></selector>
其中
@drawable/on为选择时checkbox的图像,@drawable/off反之.
还注意到菜单中第一项上方为圆角,中间项为四角都为方,最后一项为下部圆角,这个就是通过设置不同的背景图片实现的了,具体不细表.
<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 模仿墨迹天气设置界面布局
- Android UI控件之CheckBox实现墨迹天气设置布局界面(漂亮)
- 墨迹天气-模仿主页面ui
- 墨迹天气新玩法
- Android UI开发第四十一篇——墨迹天气3.0引导界面及动画实现
- Android UI开发第四十一篇——墨迹天气3.0引导界面及动画实现
- Android UI开发第四十一篇——墨迹天气3.0引导界面及动画实现
- 使用Property Animation实现墨迹天气3.0引导界面及动画实现
- Android UI开发第四十一篇——墨迹天气3.0引导界面及动画实现
- 墨迹天气3.0引导动画
- 墨迹天气3.0引导动画
- 高仿墨迹天气黄历
- 仿墨迹天气折线图
- 默认墨迹天气 下雪效果
- 墨迹天气分享图标优化
- GridView + ViewFlipper布局界面,模仿“机锋市场”
- Fragment+TabHost模仿新浪新闻布局界面
- Fragment+TabHost模仿新浪新闻布局界面
- c++高级---c++类的内部定义比较特殊的东西(类型,常量等)
- 黑马程序员——JAVA学习日志8
- effective C++ 笔记-02-内存管理03
- linux磁盘分区
- JS实现Map
- 模仿墨迹天气设置界面布局
- Win8风格的按钮、ToggleButton、SeekBar
- hdu 1517 A Multiplication Game
- PING不通的原因
- Netgear wndr3700v2 路由器刷OpenWrt打造全能服务器(五)SVN服务
- 概率算法 -- 从集合中选取N个不重复的元素
- 【网络流第二步】Hdu 1532——Drainage Ditches 邻接矩阵版
- uva 11100 - The Trip, 2007(贪心)类似于一道LIS题目
- 国内首套免费的《Nutch相关框架视频教程》(1-16)