Reputation: 21
I designed my layout on emulator with resolution 1920*1080 and all thing were good but now I install on my device with resolution 1280*720 and it's not good and all thing (ImageView and TextView) seems longer than 1920*1080 resolution.although I use from dp
for ImageView and sp
for TextView but they are longer.I must design layout for this resolution or several resolution? I want to be same in different.what should i do?
Upvotes: 1
Views: 172
Reputation: 1892
Try adding this line in your build.gradle
(Module: app) in dependencies
:
implementation 'com.intuit.sdp:sdp-android:1.0.6'
And then express your dimension in xml file with:
"@dimen/_[number]sdp"
For example, a TextView
will become so:
<TextView
android:id="@+id/text_view_sample"
android:layout_width="@dimen/_300sdp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_20sdp"
android:layout_marginLeft="@dimen/_20sdp"
android:layout_marginTop="@dimen/_58sdp"
android:textSize="@dimen/_15sdp" />
It won't be precise to the millimeter, but it's more precise than using just dp
and sp
.
Important: Don't forget to "sync now" the gradle when you add lines in .gradle
files
Library source: https://github.com/intuit/sdp
Upvotes: 2