Sunday, 11 August 2013

Android @style resource is not resolved

Android @style resource is not resolved

I am using Android Studio for an android app development. I have a style
resource inside ..../src/main/res/values -
colors.xml
dimens.xml
strings.xml
styles.xml
I have a couple of styles defined in the Styles.xml file and the studio
throws error saying that the style cannot be resolved where it resolves
and applies to one LinearLayout in the same activity code and from the
same styles.xml file. I am trying to apply another style to the Button
inside that LinearLayout that works.
In the 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 the activity_login.xml -
<Button style="@style/LoginButton"
android:id="@+id/sign_in_button"
/>
The error 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)

No comments:

Post a Comment