Forum Xamarin Xamarin.Android

Can't set "layout_width" and "layout_height" in style

the_duckthe_duck ATMember
edited September 2016 in Xamarin.Android


I'm currently working on Android project. In some layouts I use placeholders to properly center a view using "android:weightSum". I decided on using a central defined style as all of them use the same attributes. This includes the definition of "layout_width" and "layout_weight" in this style. The problem is that the designer throws an exception as "layout_width" and "layout_weight" aren't declared. From programming with Android Studio I know that it I solely can declare "layout_width" and "layout_weight" using a style. Is there some kind of workaround?

Thanks in advance.

<LinearLayout style="@style/PlaceHolder" />

<style name="PlaceHolder"> <item name="android:layout_height">match_parent</item> <item name="android:layout_width">match_parent</item> <item name="android:layout_weight">1</item> </style>

Sign In or Register to comment.