今天,再給大家分享一下QQ設置界面的UI布局實現,不羅嗦,直接上圖
設置主界面
<ignore_js_op>
皮膚設置界面
<ignore_js_op>
流量統計界面
<ignore_js_op>
好友設置界面(其實這個不在設置界面里,工程里有該ACTIVITY,就在最后加上了)
<ignore_js_op>
在開發應用程序的過程中我們有很大的機會需要用到參數設置功能
那么在Android應用中,我們如何實現參數設置界面及參數存儲呢
答案是使用PreferenceActivity,相信大家並不陌生
只不過系統自帶的樣式黑布隆冬的,看起來很不美觀,難登大雅之堂
只要我們稍加修飾,便可扭轉乾坤,化別扭為和諧
主要是在MainFeast配置文件里給ACTIVITY加上自定義的樣式
<activity android:name=".SettingActivity"
android:label="設置與幫助"
android:theme="@style/Default"
android:configChanges="keyboardHidden|orientation" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
且看 Style.xml配置文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomWindowTitleBackground">
<item name="android:background">@drawable/skinpic_green</item>
</style>
<style name="CustomWindowTitleText" >
<item name="android:textSize">20dip</item>
<item name="android:textColor">#FFffffff</item>
<item name="android:paddingLeft">10dp</item>
</style>
<style name="customCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/selector_checkbox</item>
</style>
<style name="customListView" parent="@android:style/Widget.ListView">
<item name="android:scrollbarSize">10.0dip</item>
<item name="android:scrollbarThumbVertical">@drawable/scrollbar_handle_vertical</item>
<item name="android:listSelector">@drawable/selector_list</item>
<item name="android:cacheColorHint">#00000000</item>
</style>
<style name="Default.NoTitleBar" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:textColorPrimaryInverse">@android:color/black</item>
<item name="android:windowBackground">@color/window_bg</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowTitleSize">42.0dip</item>
<item name="android:windowTitleStyle">@style/CustomWindowTitleText</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
<item name="android:checkboxStyle">@style/customCheckBox</item>
<item name="android:listViewStyle">@style/customListView</item>
</style>
<style name="Default" parent="@style/Default.NoTitleBar">
<item name="android:windowNoTitle">false</item>
</style>
</resources>
本例只用到了CheckBox和ListView,如果大家的設置界面有用到其它控件
如editText,radioButton之類的,只需依葫蘆畫瓢,加上editTextStyle,radioButtonStyle即可
如需自定義Preference布局,則需派生一個Preference子類,並配置相關XML布局文件
詳情請見:http://blog.csdn.net/aomandeshangxiao/article/details/6659346
在此就不多言了
像好友資料這樣的UI布局還是很常見的,很多人可能不知道怎么實現
主要是采用了線形布局,一個白框是個linearlayout,白框內一行行的同樣是linearlayout
分割線則是采用了shape的配置布局
類似
<?xml version="1.0" encoding="UTF-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffe0e0e0" />
</shape>
當然類似布局的實現未必都是如此,這里只是給大家提供一個思路
好了其它的也不多說了,自己下工程看吧。
來源:eoeAndroid開發者社區。