-1

我希望 ImageView 保持其纵横比与 layout_height=match_parent 但我不知道为什么会这样?

鲍勃

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <ImageView
           android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            android:background="@drawable/bob" />
        <TextView
            android:gravity="center"
          android:textAppearance="@style/TextAppearance.AppCompat.Headline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Bob" />
    </LinearLayout>
</LinearLayout>
4

2 回答 2

1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <ImageView
           android:layout_width="wrap_content"
            android:layout_height="match_parent"

            android:background="@drawable/bob" />
        <TextView
            android:gravity="center"
          android:textAppearance="@style/TextAppearance.AppCompat.Headline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Bob" />
    </LinearLayout>
</LinearLayout>
于 2018-09-07T09:10:46.420 回答
0

用于在全图像视图中设置 scaletype=fitxy

于 2018-09-07T09:10:00.357 回答