0
派生視圖的所有屬性這是我layout.xml派生從styles.xml所有視圖參數Android的佈局XML文件應該從styles.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res /android"
android:layout_width="match_parent"
style="@style/DataContainer">
<ImageView
android:id="@id/df_flight_logo"
style="@style/FlightLOGO"
/>
<TextView
android:id="@id/flight_name"
style="@style/FlightName"
/>
<TextView
android:id="@id/flight_price"
style="@style/FlightPrice"
/>
</RelativeLayout>
這是我styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="DataContainer">
<item name="android:layout_height">125dp</item>
<item name="android:background">#ffffff</item>
</style>
<style name="FlightLOGO">
<item name="android:layout_height">25dp</item>
<item name="android:layout_weight">25dp</item>
<item name="android:background">@drawable/background</item>
</style>
<style name="FlightName">
<item name="android:layout_height">32dp</item>
<item name="android:background">#b2b2b2</item>
</style>
<style name="FlightPrice">
<item name="android:layout_height">12dp</item>
<item name="android:layout_marginLeft">18dp</item>
<item name="android:background">#b2b2b2</item>
</style>
</resources>
所以我應該把所有的視圖屬性(寬度,高度,邊距,填充)到styles.xml?或特定視圖(按鈕樣式,文本樣式)屬性爲styles.xml?
通過將所有的屬性都syles.xml,我想用同樣的layout.xml爲不同尺寸的設備。對不同大小的設備有不同的styles.xml。這種設計方法好嗎? –
@AnilKushwaha我已編輯 –
這是我的文本視圖 這是我的styles.xml –