How to make a Listview responsive?

Asked

Viewed 142 times

1

I wanted the items from ListView appear with a responsive size at different screen resolution, how do I? Because I set a size of images and text, which gets big on small devices

Listview items:

android:orientation="vertical">

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

    <ImageView
        android:id="@+id/imagemview"
        android:layout_width="150dp"
        android:layout_height="150dp"
          android:layout_marginLeft="5sp"
        />

    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textSize="20dp"
        android:layout_marginLeft="25sp"
        android:textStyle="bold"

        android:gravity="center_vertical"
        android:textColor="#FF000000"
    />

</LinearLayout>

How do I open normal on different sizes of screens?

  • To leave responsive can use the weightSum

  • Code is missing?

  • The basic rule is to involve each Linearlayout in a Framelayout.

  • match_parenrt does this, aligns according to your screen, put your complete layout.

1 answer

0

Use dimens to set the size of items for each screen.

<resources>
    <dimen name="action_button_min_width">56dp</dimen>
    <dimen name="indeterminate_progress_size">32dp</dimen>
</resources>

Reference link: Android Developers - dimen.xml

Browser other questions tagged

You are not signed in. Login or sign up in order to post.