局域网中电脑每次重启都要重新添加打印机之问题解决
2011-08-19 13:45
603 查看
Android中的控件的自定义性是很强的,正因为如此我们可以更容易的做出漂亮的UI。下面就
是通过自定义CheckBox实现墨迹天气,qq等等的设置界面。
话不多说,直接上效果图吧!
![](http://img.my.csdn.net/uploads/201303/17/1363520368_9824.png)
效果还算可以吧?下面来看看具体的实现吧! 主xml文件:
可以将重复的代码添加到style.xml的文件中去设置为一种样式,在需要这种样式的时候在使用! 下面是该小项目的样式文件。
style文件:
首先看复选框的实现:
值得注意的是上面中第一项和第三项的边框都是圆形的,而中间是方的,这只是设置的
背景图片,这里就不深究了,好了Over!
完整源码:
本文出自 “kiritor” 博客,请务必保留此出处http://kiritor.blog.51cto.com/7400479/1226746
是通过自定义CheckBox实现墨迹天气,qq等等的设置界面。
话不多说,直接上效果图吧!
![](http://img.my.csdn.net/uploads/201303/17/1363520368_9824.png)
效果还算可以吧?下面来看看具体的实现吧! 主xml文件:
<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" 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/SettingItemBottom"使用了style.xml这个文件来控制样式。在Android开发中会有很多控件的属性是重复出现的,
可以将重复的代码添加到style.xml的文件中去设置为一种样式,在需要这种样式的时候在使用! 下面是该小项目的样式文件。
style文件:
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="AppTheme" parent="android:Theme.Light" /> <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> <style name="MySettingText"> <item name="android:layout_margin">10dp</item> <item name="android:layout_weight">6</item> </style> <style name="SettingItemTop"> <item name="android:layout_marginTop">10dp</item> <item name="android:layout_marginLeft">10dp</item> <item name="android:layout_marginRight">10dp</item> <item name="android:background">@drawable/setting_list_top</item> </style> <style name="SettingItemMiddle"> <item name="android:layout_marginLeft">10dp</item> <item name="android:layout_marginRight">10dp</item> <item name="android:background">@drawable/setting_list_middle</item> </style> <style name="SettingItemBottom"> <item name="android:layout_marginBottom">10dp</item> <item name="android:layout_marginLeft">10dp</item> <item name="android:layout_marginRight">10dp</item> <item name="android:background">@drawable/setting_list_bottom</item> </style> </resources>上述效果的主要代码也就是这些了,具体是如何实现的呢?
首先看复选框的实现:
<CheckBox style="@style/MyCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content"/>抓出他的样式:可以的出的checkBox的样式使用了selector
<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>在资源文件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>这样就定义了,checkBox选中和没选中所显示的图片按钮,checkBox部分也就完成了!
值得注意的是上面中第一项和第三项的边框都是圆形的,而中间是方的,这只是设置的
背景图片,这里就不深究了,好了Over!
完整源码:
本文出自 “kiritor” 博客,请务必保留此出处http://kiritor.blog.51cto.com/7400479/1226746
相关文章推荐
- 解决win7系统重启后ip丢失问题,即每次电脑重启都要重新设置ip地址,重启后ip地址没了
- Win7系统中添加局域网中别人共享的打印机 出错, 找不到驱动程序 的问题的解决
- 每次重启电脑后VSS客户端重新连接SourceSafe的问题
- 解决自动添加局域网内打印机的问题
- 添加的网络打印机每次重启或者关机之后都会出现打印机脱机情况的解决办法
- 打印机每次都要重新连接后才能打印,解决办法
- 办公室常见问题解决:不能连接局域网的共享打印机
- 解决惠普P10008激光打印机重启驱动消失的问题
- vs2015 vassistX 每次重启之后都要重新破解的解决办法
- apicloud git-svn 地址冲突,导致代码管理功能不可用.这个问题是由 windows 系统自身DLL加载机制引起的.一般重启电脑即可解决
- 问题:手机访问不了同一个局域网内的电脑上的网站 (已解决)
- 联想笔记本电脑键盘一按capslk键盘就被锁定,除了重启解锁但还是没解决根本问题,其他解决的办法?
- 电脑重新开机日期时间错误不对问题解决方法
- 解决Eclipse每次运行Android项目都重新打开一个模拟器问题
- 解决在局域网内XP不能访问win8共享的打印机问题
- 如何解决windows7桌面小工具每次开机都要重新开启的问题
- “浏览器设置从上次停下的地方继续,但是电脑重启打开后还是主页”问题的解决办法
- ubuntu设置静态IP及修复重启电脑后DNS须重新设置的问题
- 解决电脑重启后声音图标不显示的问题