我的目标是API级别21,最小目标也是21(我目前仅支持Lollipop,这是一个值得学习的宠物项目)。我在使用自定义ListView项布局时遇到问题。这是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/test_list_item_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:background="#FF0000"
android:src="@drawable/ic_test"
tools:ignore="ContentDescription"/>
<TextView
android:id="@+id/test_list_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/test_list_item_icon"
android:textSize="50sp"/>
</RelativeLayout>
这是它的外观(图标的红色背景颜色仅是为了查看实际视图的大小):
我希望图像视图的行为如下:在布局的“开始” /左侧占用可用的垂直空间,按比例缩放图像,并增大宽度,以便可以完全显示图像,像这样(请原谅我的金手指技能):
是否有可能?
最后,我决定再创建一个图标大小xxxhdpi,现在看起来一切都很好。非常感谢@ corsair992在其中一项注释中提供了有关该错误的信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句