Android 如何降低自定义listview中的行高

Android 如何降低自定义listview中的行高,android,listview,row,reduce,Android,Listview,Row,Reduce,我使用rowlayout.xml和自定义适配器创建了一个自定义listview。heach行有一对TextVews和background,问题是如果我为行设置了背景图像,就无法降低高度。如果退出它,高度是如此之小 我需要创建一个带有背景的自定义行,并将高度降低到我无法做到的程度,我尝试更改re row.xml height,但它不起作用。在android的ui visor中,它似乎可以工作,但当我运行它时,行的大小从未改变 这是该行的代码 <?xml version="1.0" encod

我使用rowlayout.xml和自定义适配器创建了一个自定义listview。heach行有一对TextVews和background,问题是如果我为行设置了背景图像,就无法降低高度。如果退出它,高度是如此之小

我需要创建一个带有背景的自定义行,并将高度降低到我无法做到的程度,我尝试更改re row.xml height,但它不起作用。在android的ui visor中,它似乎可以工作,但当我运行它时,行的大小从未改变

这是该行的代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="80dp"
    android:orientation="horizontal"
    android:paddingLeft="@dimen/lateral_margin"
    android:paddingRight="@dimen/lateral_margin"
    android:background="@drawable/list_detail"
    >

    <TextView
        android:id="@+id/textItemOnList"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"  />

    <TextView
        android:id="@+id/textMoneyOnList"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true" />

</RelativeLayout>

您必须将背景图像的大小调整为与listview行相同的大小

`   public static Bitmap resizeBitmap(Bitmap photo, float x, float y) {

        try {
            // get current bitmap width and height
            int width = photo.getWidth();
            int height = photo.getHeight();

            // determine how much to scale
            float scaleWidth = x / width;
            float scaleHeight = y / height;

            // create the matrix for the manipulation
            Matrix matrix = new Matrix();
            // resize the bitmap
            matrix.postScale(scaleWidth, scaleHeight);

            // recreate the new bitmap
            Bitmap resizebitmap = Bitmap.createBitmap(photo, 0, 0, width,
                    height, matrix, false);
            return resizebitmap;

        } catch (NullPointerException e) {
            e.printStackTrace();
        } catch (OutOfMemoryError e) {
            e.printStackTrace();
            System.gc();
        }
        return null;
    }
`

最后,我减少了图像资源,但你的答案是编程的方式,它将工作