here on XML Attributesセクションに基づいて、 my で次のように指定しますdimens.xml
。
<dimen name="match_parent">-1dp</dimen>
<dimen name="main_left_menu_user_account_width">@dimen/match_parent</dimen>
<dimen name="main_left_menu_user_account_height">@dimen/match_parent</dimen>
次に、レイアウトで両方のディメンションを使用します。
<ImageView
android:id="@+id/userAccountImage"
android:background="@drawable/user_account"
android:layout_width="@dimen/main_left_menu_user_account_width"
android:layout_height="@dimen/main_left_menu_user_account_height" />
次に、プレビューするとGraphical Layout
、次のように不平を言います。
layout_width 属性を指定する必要があります。
layout_height 属性を指定する必要があります。
実際に、で match_parent と等しい値を定義できますdimens.xml
か?
アップデート:
私もこれを試しましたが、プレビューはまだ不平を言っています:
<dimen name="main_left_menu_user_account_width">-1dp</dimen>
<dimen name="main_left_menu_user_account_height">-1dp</dimen>
私は正常に使用しwrap_content
ています(Graphical Layout
まったく文句を言いません):
<dimen name="wrap_content">-2dp</dimen>
<dimen name="main_right_menu_width">@dimen/wrap_content</dimen>
<dimen name="main_right_menu_height">@dimen/wrap_content</dimen>