2012-01-12 46 views
0

我已經定義了下面的樣式樣式修改繼承屬性:安卓:從

<style name="Activity"> 
    <item name="android:layout_width">fill_parent</item> 
    <item name="android:layout_height">fill_parent</item> 
    <item name="android:background">@drawable/background</item> 
    <item name="android:orientation">vertical</item> 
</style> 

但我想在佈局定義layout_height =「WRAP_CONTENT」,繼承了attributtes的休息:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
style="@style/Activity" 
android:layout_height="wrap_content"> 
... 
</LinearLayout> 

但它繼續應用fill_parent高度。

可能嗎?任何解決方法?

回答

0

新樣式

<style name="Activity"> 
<item name="android:layout_width">fill_parent</item> 
<item name="android:background">@drawable/background</item> 
<item name="android:orientation">vertical</item> 

FILL_PARENT風格

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android」 style="@style/Activity" android:layout_height="fill_parent」> </LinearLayout> 

包裹內容風格

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android」 style="@style/Activity" android:layout_height="wrap_content"> 

+0

它不能解決我的問題!默認的屬性是android:layout_height =「fill_parent」,但我需要在一個佈局中覆蓋它。如果我把你的解決方案,我必須在所有的佈局定義它。我不知道是否沒有任何解決方案,我必須這樣做。 – joseantgv 2012-01-13 08:11:08

0

如果要更改佈局xml中的layout_height,則可能還需要設置layout_width。