欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android Style.xml的應(yīng)用詳解及代碼實(shí)現(xiàn)

 更新時間:2016年10月26日 10:17:15   投稿:lqh  
這篇文章主要介紹了Android Style.xml的應(yīng)用詳解及代碼實(shí)現(xiàn)的相關(guā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)文章

最新評論