Android 列表中的视图大小不正确

Android 列表中的视图大小不正确,android,listview,layout,size,height,Android,Listview,Layout,Size,Height,我有一个列表视图和一个适配器。我的问题是列表中的行总是“wrap content”,尽管我特别将高度指定为“150dp” 这是我的适配器: private class LiveEventsAdapter extends BaseAdapter { @Override public View getView(int position, View convertView, ViewGroup parent) { View contentView = convertV

我有一个列表视图和一个适配器。我的问题是列表中的行总是
“wrap content”
,尽管我特别将高度指定为
“150dp”

这是我的适配器:

private class LiveEventsAdapter extends BaseAdapter {

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View contentView = convertView;
        if (contentView == null) {
            LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            contentView = inflater.inflate(R.layout.live_match_row, null);
            TypefaceManager.getInstance(LiveMatchActivity.this).assignTypeface(contentView);
        }

        if (events != null) {
            Event event = events.getEventsList().get(position);

            TypefaceManager typefaceManager = TypefaceManager.getInstance(LiveMatchActivity.this);
            TextView eventText;
            TextView minute;
            ImageView eventIcon;

            minute = (TextView) contentView.findViewById(R.id.live_match_minute);
            if (event.getOrientation().equals("home")) {
                eventText = (TextView) contentView.findViewById(R.id.home_team_event_text);
                eventIcon = (ImageView) contentView.findViewById(R.id.home_team_event_img);
            } else {
                eventText = (TextView) contentView.findViewById(R.id.away_team_event_text);
                eventIcon = (ImageView) contentView.findViewById(R.id.away_team_event_img);
            }
            minute.setText(event.getMinute() + "\'");
            eventText.setText(event.getDescription());
            minute.setTypeface(typefaceManager.getTypeface("bold"));
            eventText.setTypeface(typefaceManager.getTypeface("bold"));
        }   
}
这就是我如何
“setadapter”

这就是我的
行布局

<?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="150dp"
android:background="@drawable/background_button" >

<TextView
    android:id="@+id/live_match_minute"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="82&apos;" />

<TextView
    android:id="@+id/home_team_event_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="false"
    android:layout_alignRight="@+id/home_team_event_img"
    android:layout_centerVertical="true"
    android:paddingLeft="4dp"
    android:paddingRight="4dp" />

<ImageView
    android:id="@+id/home_team_event_img"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentTop="true"
    android:layout_centerVertical="true"
    android:layout_marginRight="4dp"
    android:layout_toLeftOf="@+id/live_match_minute" />

<ImageView
    android:id="@+id/away_team_event_img"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="false"
    android:layout_centerVertical="true"
    android:layout_marginLeft="4dp"
    android:layout_toRightOf="@+id/live_match_minute" />

<TextView
    android:id="@+id/away_team_event_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="false"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/away_team_event_img"
    android:paddingLeft="4dp"
    android:paddingRight="4dp" />

为什么我的列表中的行总是设置为相同的大小,不管我输入什么?

这不起作用

这是你应该做的

<?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="wrap_content" >

    <RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="150dp"
    android:background="@drawable/background_button" >

        <TextView
            android:id="@+id/live_match_minute"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="82&apos;" />

    </RelativeLayout>
</RelativeLayout>

基本上,添加另一个布局并指定该布局的高度。 使用适配器视图时,为根布局指定高度不起作用

<?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="wrap_content" >

    <RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="150dp"
    android:background="@drawable/background_button" >

        <TextView
            android:id="@+id/live_match_minute"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="82&apos;" />

    </RelativeLayout>
</RelativeLayout>