I am using Android Studio to develop Android applications. I have a style resource inside .... / src / main / res / values -
colors.xml dimens.xml strings.xml styles.xml
I have several styles defined in Styles.xml, and the studio throws an error saying that the style cannot be resolved where it is allowed and applied to the same LinearLayout in the same activity code and from the same styles.xml file. I am trying to apply a different style to a Button inside this LinearLayout that works.
In styles -
<style name="LoginButton"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_marginTop">10dp</item> <item name="android:layout_marginLeft">25dp</item> <item name="android:layout_marginRight">25dp</item> <item name="android:background">@color/navy_blue</item> <item name="android:textColor">@color/white</item> <item name="android:text">@string/action_sign_in</item> <item name="android:paddingLeft">50dp</item> <item name="android:paddingRight">50dp</item> <item name="android:layout_gravity">center</item> </style>
And on activity_login.xml -
<Button style="@style/LoginButton" android:id="@+id/sign_in_button" />
Showroid android studio shows -
Rendering Problems NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts. <Button> does not set the required layout_width attribute: Set to wrap_content, Set to match_parent <Button> does not set the required layout_height attribute: Set to wrap_content, Set to match_parent Or: Automatically add all missing attributes Couldn't resolve resource @style/LoginButton (6 similar errors not shown)
source share