Samsung S3 - 720x1280, xhdpi, 306ppi
Motorola Moto X - 720x1280, xhdpi, 312 ppi
I need to provide different dimen
for these devices.
I have read Supporting Multiple Screens but still didn't found a solution
Looks like problem because Motorola Moto X
haven't hardware buttons (back, menu, home)
How can I achieve this?
You can use google library PercentRelativeLayout
with this library you can set width
, height
and margin
of your views by percentage which is great because in all screen they look the same and of course it is not hard to code it. Here example:
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
app:layout_marginTopPercent="25%"
app:layout_marginLeftPercent="25%"/>
</android.support.percent.PercentRelativeLayout>
you must add this line in your build.gradle
dependencies {
compile 'com.android.support:percent:23.2.0'
}
and official documentation by Google https://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html Hope this help for your case!