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.
LinearLayout : is a ViewGroup that aligns all children in a single direction, vertically or horizontally. RelativeLayout : is a ViewGroup that displays child views in relative positions. AbsoluteLayout : allows us to specify the exact location of the child views and widgets.
LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. You can specify the layout direction with the android:orientation attribute.
ConstraintLayout helps you to avoid using nested layouts and it causes better performance. it's not wrong to use it for everything but if you know that you are not going to have nested layouts, for example, three Textview s respectively, you can use LinearLayout.
With the help of ConstraintLayout, we can position our UI components in any sort of order whether it may be horizontal or vertical. But in the case of Linear Layout, we can only arrange our UI components either in a horizontal or in a vertical manner.
I think what you want is style="@style/VerticalThemeLayoutInputs"
.
E.g.
<LinearLayout
style="@style/VerticalThemeLayoutInputs">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With