Android Style.xml的應(yīng)用詳解及代碼實(shí)現(xiàn)
Style.xml的妙用
Style.xml之于Android猶如css之于Jsp
妙用
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/sensor" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>
這樣的布局文件是很正常的。但是不如這樣好
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/all_match" android:orientation="vertical" > <TextView android:id="@+id/sensor" style="@style/all_fill" /> </LinearLayout>
省時省力,一眼還能看出是什么布局方式。只需要在Style.xml 中添加 這些代碼即可
<style name="all_fill" > <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">fill_parent</item> </style> <style name="all_match" > <item name="android:layout_width">match_content</item> <item name="android:layout_height">match_content</item> </style> <style name="width_fill" > <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">match_content</item> </style> <style name="height_fill" > <item name="android:layout_width">match_content</item> <item name="android:layout_height">fill_parent</item> </style>
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Android?Flutter實(shí)現(xiàn)任意拖動的控件
使用flutter開發(fā)是需要控件能拖動,比如畫板中的元素,或者工具條等,所以本文為大家準(zhǔn)備了Flutter實(shí)現(xiàn)任意拖動控件的示例代碼,希望對大家有所幫助2023-07-07Android提高之藍(lán)牙傳感應(yīng)用實(shí)例
這篇文章主要介紹了Android的藍(lán)牙傳感應(yīng)用實(shí)例,對于Android項(xiàng)目開發(fā)來說非常實(shí)用,需要的朋友可以參考下2014-08-08詳解android使用ItemDecoration 懸浮導(dǎo)航欄效果
本篇文章主要介紹了Android 最流行的吸頂效果的實(shí)現(xiàn)及代碼,非常具有實(shí)用價值,需要的朋友可以參考下。2017-01-01Crashlytics Android 異常報告統(tǒng)計管理(詳解)
下面小編就為大家?guī)硪黄狢rashlytics Android 異常報告統(tǒng)計管理(詳解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-05-05Android中自定義ContentProvider實(shí)例
應(yīng)用A(TestBaidu)調(diào)用另外一個應(yīng)用(TestContentProvider)即自定義ContentProvider的使用,其它應(yīng)用調(diào)用該ContentProvider,具體如下,感興趣的朋友可以參考下哈2013-06-06Android studio 3.0 查看手機(jī)文件系統(tǒng)的方法(超簡單)
本文給大家分享Android studio更新到3.0版本之后,查看手機(jī)文件系統(tǒng)的方法,需要的朋友參考下吧2017-11-11Android編程使用自定義shape實(shí)現(xiàn)shadow陰影效果的方法
這篇文章主要介紹了Android編程使用自定義shape實(shí)現(xiàn)shadow陰影效果的方法,涉及Android中xml文件布局的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11Android?autojs隨時翻譯剪貼板單詞實(shí)現(xiàn)示例
這篇文章主要為大家介紹了Android?autojs隨時翻譯剪貼板單詞,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09