Simply - how place one view on the top of another view (which can shrink) in the strictly defined place regardless of screen resolution and density?
Example - place TextView on the top of image always on pyramides. When I am using margins (Frame or Relative layout) with dp units they fail on different screen size :(
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image" />
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="30dp"
android:layout_gravity="left|bottom" />
</FrameLayout>
When I am using margins (Frame or Relative layout) with dp units they fail on different screen size
yes they will always fail due to that other devices has different dp.
solution:
you can always use the values
folder of your res
folder where you put your values to the dimens.xml
so your margin will always change depending on the device you are testing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.