LinearLayout does not set the required layout_height attribute

I make a layout and apply some styles. So:

<style name="LayoutSmallMap">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">180dip</item>
        <item name="android:background">@drawable/rounded_corner</item>
        <item name="android:layout_margin">5dip</item>
        <item name="android:padding">3dip</item>
</style>

And I use this:

<LinearLayout 
       style="@style/LayoutSmallMap">

</LinearLayout>

But when I test the phone before it gives an error, and now it says:

LinearLayout does not set the required layout_height attribute

Does he not find an attribute in my style?

I don't know if this was the best solution, but it worked for me: Target SDK: 2.3 and minSdkVersion = "7"

+5
source share
2 answers

You cannot use android: layout_width and android: layout_height in styles. Change the code as follows.

<style name="LayoutSmallMap">
        <item name="android:background">@drawable/rounded_corner</item>
        <item name="android:layout_margin">5dip</item>
        <item name="android:padding">3dip</item>
</style>


<LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="180dip"  
       style="@style/LayoutSmallMap">

</LinearLayout>
+1
source

try it

<style name="LayoutSmallMap">         
    <item name="android:background">@drawable/rounded_corner</item>
    <item name="android:layout_margin">5dip</item>
    <item name="android:padding">3dip</item>
</style>

layout

<LinearLayout 
    android:layout_width="fill_parent"
   android:layout_height="180dib"
    style="@style/LayoutSmallMap">

 </LinearLayout>
0
source

All Articles