我有一个 ImageView 包装 this image :
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:scaleType="fitStart"
android:src="@drawable/oncmap"/>
在它的正下方,一个TextView。不幸的是,它会根据设备的屏幕尺寸将其推下 View 或移出 View 。
http://i.imgur.com/CuVFK5P.png
http://i.imgur.com/6wzMebV.jpg
我可以“破解”它,但它宁愿不...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="16dp"
android:orientation="vertical"
tools:context="MapFragment">
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/oncmap"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Neptune"
style="@style/sectionHeader"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="16dp"
android:text="@string/info"
style="@style/text"/>
最佳答案
将以下字段添加到 ImageView:
android:scaleType="fitXY"
android:adjustViewBounds="true"
关于java - ImageView 不包装内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21203189/