gosulove
gosulove

Reputation: 1645

Android Image is not proportionate for phone and Tablet size

I am trying to display a imageview and 2 textview using listfragment. I design it for the purpose of displaying on Tablet. It looks ok. However, if i use phone to view it, the effect is different. As you can see from the screenshot .

enter image description here

Is it possible to make the phone view is same as the Tablet view?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="0dp"
        android:layout_height="200dp"
        android:id="@+id/img"
        android:src="@drawable/img_1"
        android:layout_weight="1" />

    <RelativeLayout
        android:orientation="horizontal"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="Name"
            android:id="@+id/name"
            android:layout_alignParentTop="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="Price"
            android:id="@+id/price"
            android:layout_below="@+id/name" />
    </RelativeLayout>
</LinearLayout>

Upvotes: 1

Views: 154

Answers (1)

Neelay Srivastava
Neelay Srivastava

Reputation: 1231

I was facing the same thing and I came to know about sdp which changes according to the device try this Or you can make a separate layout for different screen sizes by this`

Upvotes: 2

Related Questions