سؤال

In my app am using customized listed view with text view and Buttons.The screen size is 4.65" 720p(720X1280 : xhdpi),device take this resolution from layout-large folder.when i run it on device.the list view item and header display not fit to the screen like image shown below,some empty space in the end of row.Its not able to fit to the screen.Can any one know please help me to solve this issue.

enter image description here

Header XML Coding

<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/search_lay"
android:layout_marginTop="1dp"
android:background="#e8e8e8" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:layout_marginLeft="32dp"
    android:text="Item(s)"
    android:textColor="#dd1713"
    android:textSize="13sp" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginLeft="48dp"
    android:layout_toRightOf="@+id/textView1"
    android:text="Price(Rs.)"
    android:textColor="#dd1713"
    android:textSize="13sp" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginLeft="18dp"
    android:layout_toRightOf="@+id/textView3"
    android:text="Qty"
    android:textColor="#dd1713"
    android:textSize="13sp" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:layout_marginLeft="28dp"
    android:layout_toRightOf="@+id/textView2"
    android:text="Total(Rs.)"
    android:textColor="#dd1713"
    android:textSize="13sp" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:layout_marginLeft="3dp"
    android:text="Fav"
    android:textColor="#dd1713"
    android:textSize="13sp" />
</RelativeLayout>

Customized List-view XML Coding

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent" >

<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#ffffff" >

<TextView
    android:id="@+id/orderlist_product_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView"
    android:visibility="gone" />

<RelativeLayout
    android:layout_width="30dp"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/fav_img"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:background="@drawable/fav_order_list_btn" />

    <Button
        android:id="@+id/special_inst_btn"
        android:layout_width="25dp"
        android:layout_height="18dp"
        android:layout_below="@+id/fav_img"
        android:layout_centerHorizontal="true"
        android:background="@drawable/special_inst_btn_in_orderlist"
        android:gravity="center"
        android:text="+"
        android:textColor="#ffffff"
        android:textSize="14sp" />

</RelativeLayout>

<TextView
    android:id="@+id/order_list_itemname"
    android:layout_width="95dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginLeft="1dp"
    android:text="Item name"
    android:textColor="#000000"
    android:textSize="12sp"
    android:typeface="serif" />

<RelativeLayout
    android:layout_width="34dp"
    android:layout_height="match_parent"
    android:layout_marginLeft="2dp" >

    <TextView
        android:id="@+id/orderlist_offer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="4dp"
        android:gravity="center"
        android:textColor="#298616"
        android:textSize="10sp" />

    <TextView
        android:id="@+id/orderlist_price"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:gravity="right"
        android:text="200.00"
        android:textColor="#000000"
        android:textSize="10sp"
        android:typeface="serif" />
</RelativeLayout>

<Button
    android:id="@+id/orderlist_minus"
    android:layout_width="25dp"
    android:layout_height="25dp"
    android:layout_gravity="center"
    android:layout_marginLeft="5dp"
    android:layout_marginTop="1dp"
    android:background="@drawable/sub_button_click" />

<EditText
    android:id="@+id/order_list_quantity"
    android:layout_width="27dp"
    android:layout_height="25dp"
    android:layout_marginTop="13dp"
    android:background="@drawable/et_bg"
    android:ems="10"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:gravity="center"
    android:inputType="number"
    android:textColor="#000000"
    android:textSize="12dp"
    android:typeface="serif" >

    <requestFocus />
</EditText>

<Button
    android:id="@+id/orderlist_plus"
    android:layout_width="25dp"
    android:layout_height="25dp"
    android:layout_gravity="center"
    android:layout_marginTop="1dp"
    android:background="@drawable/plus_btn_click" />

<TextView
    android:id="@+id/orderlist_total"
    android:layout_width="43dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="3dp"
    android:layout_marginTop="13dp"
    android:gravity="right"
    android:text="1000.00"
    android:textColor="#000000"
    android:textSize="11sp"
    android:typeface="serif" />

<Button
    android:id="@+id/orderlist_delete"
    android:layout_width="23dp"
    android:layout_height="23dp"
    android:layout_gravity="center"
    android:layout_marginLeft="3dp"
    android:layout_marginTop="1dp"
    android:background="@drawable/order_list_delete" />
</LinearLayout>

</RelativeLayout>
هل كانت مفيدة؟

المحلول

i m giving u a demo.this layout will work on all size layout,this will definitely help u @Yugesh. weight works percentage-wise on all screen.

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

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical" >

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight=".30"
            android:gravity="center_horizontal" >

            <ImageView
                android:id="@+id/image1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/image1"
                android:src="@drawable/ic_launcher" />
        </RelativeLayout>

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight=".30"
            android:text="30%" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight=".20"
            android:text="20%" />

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight=".20"
            android:text="20%" />
    </LinearLayout>

</RelativeLayout>

further more,if there is any query,then please ask...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top