How to Resize ListView Android List Box Row Size

Listview row height too high. I designed the string like this. This is a ListViewItem Layout layout file.

 <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="@drawable/list_style"
    android:gravity="center_horizontal"
    android:minWidth="25px"
    android:minHeight="25px">
  <TextView
      android:text="Text"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/forecastName"
      android:gravity="center_vertical"
      android:padding="10px" 
      android:textColor="@color/black"/>
</LinearLayout>

and this is a listview layout

   <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
             android:orientation="vertical"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:background="@drawable/list_style"
             android:minWidth="25px"
             android:minHeight="25px">
             <ListView
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:id="@+id/forecast"
                 android:divider="@drawable/separator"
                 android:dividerHeight="3px" />
         </LinearLayout>

When an element of the list of application objects has a certain height, it does not correspond to the size of the text field. How to resize a row?

+4
source share
4 answers

The problem was the size of the background image. android:background="@drawable/list_style"I am using an image from the background. so I resized the image. Thank you

+1
source

You can simply specify a fixed height in the layout of the XML strings:

android:layout_height="25dp"

: dp ( dip) px .

+5

, android:minWidth android:minHeight, .

Android .

android:height="?android:attr/listPreferredItemHeight"
+3

, : minWidth android: minHeight. .

, px. . dp px, . sp.

, . , .

0

Source: https://habr.com/ru/post/1541636/