Reputation: 257
I am have some problem with displaying design on different devices. I am do not solve this problem. This is photo - enter link description here
This is xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="39dp"
android:layout_marginLeft="39dp"
android:layout_gravity="center_horizontal"
android:background="#ffffffff">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="225.75dp"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="ItemName"
android:id="@+id/itemName"
android:layout_weight="3"
android:paddingTop="14dp"
android:paddingLeft="14dp"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="ItemPrice"
android:id="@+id/itemPrice"
android:layout_weight="1"
android:paddingRight="14dp"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="161.75dp"
android:id="@+id/itemImage"
android:layout_weight="16"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Buy 1 and Get 2 for free "
android:id="@+id/textView9"
android:layout_gravity="center_horizontal"
android:paddingBottom="25dp"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="101dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/placeholder_blue"
android:gravity="center_vertical"
android:paddingTop="26dp"
android:paddingBottom="26dp">
<Button
android:layout_width="49dp"
android:layout_height="49dp"
android:text="-"
android:id="@+id/itemMinus"
android:layout_marginLeft="48dp"
android:background="#fff"/>
<TextView
android:layout_width="match_parent"
android:layout_height="49dp"
android:text="1"
android:id="@+id/textView11"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:background="#fff"
android:textAlignment="gravity"/>
<Button
android:layout_width="49dp"
android:layout_height="49dp"
android:text="+"
android:id="@+id/itemPlus"
android:layout_marginRight="48dp"
android:background="#fff"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:background="@android:color/transparent"
android:paddingTop="38.5dp"
>
<ImageButton
android:layout_width="65.25dp"
android:layout_height="65.25dp"
android:id="@+id/itemCancel"
android:src="@drawable/cancel"
android:background="@android:color/transparent"
android:layout_marginRight="12dp"/>
<ImageButton
android:layout_width="65.25dp"
android:layout_height="65.25dp"
android:id="@+id/itemAdd"
android:src="@drawable/apply"
android:background="@android:color/transparent"
android:layout_marginLeft="12dp"/>
</LinearLayout>
</LinearLayout>
On the photo left to right:
LG g3 - 5" 1280 x 720 294 dpi samsung galaxy s5 - 5,1" 1080x1920 432 dpi samsung galaxy note 4 - 5.7" 1440x2560 515 dpi nexus 6 5.96" 1440x2560 493 dpi
the problem is that my DialogFragment displaying design on different devices. I need to make it always as the first phone (LG g3).
what am I doing wrong? I have 5 folders with pictures mdpi hdpi xhdpi xxhdpi xxxhdpi. I cut them a script in Photoshop. I checked the calculator. all the same. but still displayed crooked. I tried to use the values weight.
EDIT: All pictures displayed normal. But my DialogFragment displayed always at the center. I need to top-left corner DialogFragment was always under the button is on him and had no padding down
Upvotes: 0
Views: 128
Reputation: 1426
Why not try mixing in RelativeLayout? If you use the layout_weight it really depends on the screen size and density from my understanding and if you use RelativeLayout maybe you could align them the way you want properly. Like using its center_horizontal="true", above="@id/x", below="@id/y".
Upvotes: 1