Android アプリの開発に Android Studio を使用しています。..../src/main/res/values 内にスタイル リソースがあります -
colors.xml
dimens.xml
strings.xml
styles.xml
Styles.xml ファイルにいくつかのスタイルが定義されていますが、同じアクティビティ コード内の同じ styles.xml ファイルからスタイルが解決され、1 つの LinearLayout に適用される場所で、スタイルを解決できないというエラーがスタジオからスローされます。動作する LinearLayout 内の Button に別のスタイルを適用しようとしています。
スタイルで -
<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>
そして activity_login.xml で -
<Button style="@style/LoginButton"
android:id="@+id/sign_in_button"
/>
エラーアンドロイドスタジオが示しています -
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)