- 浏览: 1484105 次
- 性别:
- 来自: 南京
文章分类
- 全部博客 (419)
- XMPP (19)
- Android (180)
- Java (59)
- Network (4)
- HTML5 (13)
- Eclipse (9)
- SCM (23)
- C/C++ (4)
- UML (4)
- Libjingle (15)
- Tools&Softwares (29)
- Linphone (5)
- Linux&UNIX (6)
- Windows (18)
- Google (10)
- MISC (3)
- SIP (6)
- SQLite (5)
- Security (4)
- Opensource (29)
- Online (2)
- 文章 (3)
- MemoryLeak (10)
- Decompile (5)
- Ruby (1)
- Image (1)
- Bat (4)
- TTS&ASR (28)
- Multimedia (1)
- iOS (20)
- Asciiflow - ASCII Flow Diagram Tool.htm (1)
- Networking (1)
- DLNA&UPnP (2)
- Chrome (2)
- CI (1)
- SmartHome (0)
- CloudComputing (1)
- NodeJS (3)
- MachineLearning (2)
最新评论
-
bzhao:
点赞123!
Windows的adb shell中使用vi不乱码方法及AdbPutty -
wahahachuang8:
我觉得这种东西自己开发太麻烦了,就别自己捣鼓了,找个第三方,方 ...
HTML5 WebSocket 技术介绍 -
obehavior:
view.setOnTouchListenerview是什么
[转]android 一直在最前面的浮动窗口效果 -
wutenghua:
[转]android 一直在最前面的浮动窗口效果 -
zee3.lin:
Sorry~~
When I build "call ...
Step by Step about How to Build libjingle 0.4
http://www.cnblogs.com/slider/archive/2011/11/10/2245017.html
android开发包preference提供了我们一些方面的设置工具,PreferenceActivity,Preference,PreferenceScreen,CheckBoxPreference等,利用他们可以方便的建立应用程序的属性设置。如图:
有些时候,我们并不需要系统给我们的这么单调的ui,我们通常会修改一些属性,比如view的背景,字体的属性等,那么这个时候有两种选择:
1.针对单个应用程序,定义一个cutom的layout,当然这个layout跟系统的layout元素要一致(否则你怎么改呢?),然后在preference.xml(文件名你自己随便取)android:layout添加你定一个 的layout就可以了。
2.针对整个android系统,修改preference相关的属性,那么所有的用到PreferenceActivity的界面都会相应的 改变。这里只需要修改相应的系统layout文件(在framework/base/core/res/res/layout),比如 preference_category.xml等。
1.先说说地一种吧,比较常用到的。
首先,定义你的layout文件,这个layoutn你直接到framework拷下来,这里标记为custom_preference.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical" android:paddingRight="?android:attr/scrollbarSize"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15dip" android:layout_marginRight="6dip" android:layout_marginTop="6dip" android:layout_marginBottom="6dip" android:layout_weight="1"> <TextView android:id="@+android:id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceLarge" android:ellipsize="marquee" android:fadingEdge="horizontal" android:textColor="#475ad7"/> <TextView android:id="@+android:id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@android:id/title" android:layout_alignLeft="@android:id/title" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="#5ad747"/> </RelativeLayout> <!-- Preference should place its actual preference widget here. --> <LinearLayout android:id="@+android:id/widget_frame" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="vertical"/> </LinearLayout>
然后,你在些preference.xml文件的时候,应用到这个layout文件。
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <CheckBoxPreference android:key="checkbox_key" android:title="checkbox_title" android:summary="checkbox_summery" android:defaultValue="true" android:layout="@layout/custom_preference_layout"></CheckBoxPreference> </PreferenceScreen>
ok,到这里,你就像平时一样使用这个preference.xml文件就好了,你会发现字体的颜色成功改变了
2.第二种情况,需要搭建android系统的编译环境,这个环境怎么搭建这里就不说了。
直接到系统layout文件(在framework/base/core/res/res/layout),修改
preference.xml,这里只是针对上面那个例子,你当然也可以修改其他的preference相应的文件。preference.xml文件的
内容就是第一种情况的custom_preference.xml文件的内容,这里就不重复了。
修改后重新mka下系统,重启模拟器,ok,就可以看到第一种方法一样的效果了。
发表评论
-
[Android] 为Android安装BusyBox —— 完整的bash shell
2013-12-27 10:19 1421http://www.cnblogs.com/xiaowen ... -
Windows的adb shell中使用vi不乱码方法及AdbPutty
2013-12-27 10:17 7414http://www.veryhuo.com/down/ht ... -
AppMobi推出新XDK,可创建测试PhoneGap项目
2012-09-03 13:39 2541AppMobi今天发布了一个新的工具PhoneGap Mobi ... -
Sencha
2012-09-03 12:59 1141http://www.sencha.com/ Se ... -
jQuery Mobile学习
2012-09-01 12:33 1630使用Jquery Mobile设计Android通讯录 ... -
BackBone
2012-09-01 12:34 1225Backbone.js 是一种重量级javascript M ... -
jQTouch
2012-08-30 15:57 941A Zepto/jQuery plugin for mobil ... -
SwiFTP
2012-08-30 15:43 1246SwiFTP is a FTP server that run ... -
kWS
2012-08-30 15:41 1152kWS is a lightweight and fast W ... -
jQuery Mobile
2012-08-30 15:07 981http://jquerymobile.com/ -
PhoneGap
2012-08-30 15:07 1004http://phonegap.com/ -
Android Button background image pressed/highlighted and disabled states without
2012-08-06 12:49 1632http://shikii.net/blog/android- ... -
[AndriodTips]Image, saved to sdcard, doesn't appear in Android's Gallery app
2012-08-04 16:15 1116http://stackoverflow.com/questi ... -
Voice detection for Android
2012-07-23 11:39 2303Here it is, my fist JAVA applic ... -
[AndroidTip]local reference table overflow (max=512)的错误解决
2012-07-22 22:56 5961JNI层coding经常会遇到ReferenceTable o ... -
[AndroidTip]EditText如何初始状态不获得焦点?
2012-07-22 15:35 1190最简单的办法是在EditText前面放置一个看不到的Linea ... -
[AndroidTip]android textview滚动条
2012-07-21 14:29 1264本来是想做一个显示文字信息的,当文字很多时View的高度不能超 ... -
Google公布Android 4.1完整功能
2012-07-16 09:48 3140http://www.android.com/about/je ... -
Android开发:使用AudioTrack播放PCM音频数据【附源码】
2012-07-13 15:20 20779http://www.linuxidc.com/Linux/2 ... -
Android上的行车记录仪
2012-07-11 22:31 1968MyCar Recorder DailyRoads
相关推荐
上篇博文代码实现了Android自带的preference组件,本文将通过实例讲解自定义preference组件。 主要通过以下几步来实现: 1.定义需要的layout布局res->layout->xml文件; 2.通过继承Preference类,来实现自定义...
android Preference自定义样式
安卓Android源码——Preference_Demo.rar
Android中Preference的使用以及监听事件分析
Android中preference的使用,使用详解.
这是Pro Android学习系列中preference部分的例子源代码。
Preference,比如系统设置、短信都可以使用,简单而又好使用,而且Google原生Android代码中大量的使用了Preference组件。简单说, Preference组件其实就是Android常见UI组件与SharePreferences的组合封装实现。
导语:PreferenceActivity是一个方便设置管理的界面,但是对于界面显示来说比较...使用Preference的android:@layout属性 1)xml文件中preference的添加 代码如下: <Preference android:layout=”@layout/youmi_ad”
Preference主要实现一些配置数据,一些我们上次...Preference组件有ListPreference,EditTextPreference,CheckBoxPreference和SwitchPreference,相对于View中的ListView,EditText,CheckBox,Switch和RingtonePreference .
Android应用源码之Preference_Demo.zip项目安卓应用源码下载Android应用源码之Preference_Demo.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
android-support-v7-preference.jar
主要介绍了Android中删除Preference详解,很多时候删除Preference总会失败,本文着重分析删除失败的原因,需要的朋友可以参考下
Android Preference Framework源码~~~~~~~~~~~~~~~~~
An Android library for creating a nice color picker in the preference screen. You can use the inbuilt picker or any other color picker of your choice. The library can be used with the standard ...
Material Preference Library uses com.android.support:preference-v7:x.x.x support library widgets. Also it includes a color chooser dialog widget, that can be used to select accent color . Header is ...
android各种Preference的使用
Android程序 Preference应用 注册案例
Based on support-preference from Android Support Library, adding a lot of exciting features. Sample How to use add dependencies // replace with version above implementation 'moe.shizuku.preference...
NULL 博文链接:https://iaiai.iteye.com/blog/1779639