vnshetty vnshetty - 5 months ago 21
Android Question

Why is not possible for linear layout to have style attributes

I have defined a style for Linear layout but the layout is not visible in graphical view of

main.xml





main.xml.

<LinearLayout style="VerticalThemeLayoutInputs">





styles.xml

<resources>
<style name="VerticalThemeLayoutInputs">
<item name="android:background">#6699FF</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>

</style>
</resources>





Edit:

But below code will work fine but I don't want this code

<LinearLayout
android:background="#6699FF"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>





Interesting Fact

I used a
scrollview
. Within that I placed many Linear layout. Layouts properties are almost same so I decided to have a style for that. But what is happening know? the layout is not visible only in graphical-view but it works fine in emulator.

But actually what is happening? I think its due to Scroll view.

Answer

I think what you want is style="@style/VerticalThemeLayoutInputs".

E.g.

<LinearLayout
    style="@style/VerticalThemeLayoutInputs">
Comments