【发布时间】:2014-05-13 02:58:44
【问题描述】:
如果我膨胀这个项目并将其显示在我的列表视图中,则图像视图不会填充父级,即它只会拉伸到宽度但不会扩展到视图高度。
<?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"
android:layout_marginLeft="5dp">
<ImageView
android:layout_width="10dp"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="2dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:id="@+id/ID_task_item_priority"
android:src="@color/abs__background_holo_dark"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Your title"
android:id="@+id/ID_task_item_title"
android:singleLine="true"
android:ellipsize="end"
android:layout_toRightOf="@+id/ID_task_item_priority"
android:layout_marginRight="40dp"
android:textSize="25sp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ID_task_item_notes"
android:layout_below="@+id/ID_task_item_title"
android:maxLines="3"
android:ellipsize="end"
android:text="Your note"
android:layout_toRightOf="@+id/ID_task_item_priority"
android:layout_marginRight="4dp"
android:textSize="15sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/id_due_date"
android:layout_below="@+id/ID_task_item_notes"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:text="10-2-2014"
android:textSize="15sp"
/>
<CheckBox
android:id="@+id/ID_task_item_is_completed_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/ID_task_item_title"
android:layout_alignBottom="@+id/ID_task_item_title"
android:layout_alignParentRight="true"
android:focusable="false"
android:layout_marginRight="4dp" />
</RelativeLayout>
物品图片
【问题讨论】:
-
你试过添加android:scaleType="fitXY"吗?
-
在相对布局的imageview中?
-
在 imageview xml 声明中是的
-
<ImageView android:layout_width="10dp" android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_marginTop="2dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginBottom="5dp" android:scaleType="fitXY" android:id="@+id/ID_task_item_priority" android:src="@color/abs__background_holo_dark"/>试过这样,没有运气:(。imageview 根本没有拉伸到查看高度。 -
如果我硬编码高度,它会伸展,但如果我给 fill_parent 为什么不呢?
标签: android android-layout listview