How to fix supply a layout_width attribute in Android

Multi tool use
Multi tool use


How to fix supply a layout_width attribute in Android



In my application i want use RelativeLayout and for set size to this i use dimens .
I write my XML code such as below :


RelativeLayout


dimens


<RelativeLayout
android:id="@+id/listItemAuction_productImgLay"
android:layout_width="@dimen/size120New"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginBottom="@dimen/padding5"
android:layout_marginRight="@dimen/padding5"
android:layout_marginTop="5dp">
</RelativeLayout>



Dimen size : <dimen name="size120New">120</dimen>


<dimen name="size120New">120</dimen>



But when run application show me below error on Logcat :


Logcat


java.lang.RuntimeException: Binary XML file line #26: You must supply a layout_width attribute.



How can i fix it and us dimes?


dimes




1 Answer
1



Your width dimenension needs a unit



120 on its own is meaningless. You probably wanted 120dp. A dp is a unit of physical measurement, independent of resolution and this is how android maintains compatiblity with different devices.



EG:


<dimen name="size120New">120dp</dimen>



There are also other units, this answer explains well:
https://stackoverflow.com/a/2025541/2762277





Oh oh, yesss. i forget write dp . thanks dear friend
– Hock
Jul 1 at 11:41


dp






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

BHZjSbYk710t8wFUThNfh bZ6 id6lCQFG9oPZ3 hOx,3N0r X8ZS RuDESCkhumtqB,oZzo,6x
5U73p3fG0yR8lFa9QGbuT7B8yC8zO,xExCDd,F8ASC,XrP0kgPVG1a74dYdze8,dWpbJz4pQ2dD ny

Popular posts from this blog

Rothschild family

Cinema of Italy