android: Modify inherited attribute from a style

269 views Asked by At

i have defined the following style:

<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>

But i want to define layout_height="wrap_content" in a layout, inheriting the rest of the attributtes:

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

but it continues applying fill_parent height.

Is it possible? Any workaround?

2

There are 2 answers

1
AAV On

Your new style

<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 style

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

Wrap content style

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

0
Ifrit On

If you're changing the layout_height in your layout xml, then you might also have to set the layout_width.