Прежде всего, вам нужно использовать «match_parent» и не использовать «fill_parent» в объявлении LinearLayout, вы можете проверить «официальную документацию» здесь https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#MATCH_PARENT Еще одно наблюдение заключается в том, что вам нужно использоватьImageView как дочерний элемент, затем использовать ImageView должен быть самозакрывающимся;это означает, что он должен заканчиваться на '/>'.Тогда позвольте мне показать вам несколько быстрых идей: 1- Как естественный путь
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
><ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:src="@drawable/ocean" android:scaleType="center"/> </LinearLayout>
Тогда выглядит как 2 - Вы можете быстро импровизировать
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
/><ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:scaleType="center"/><ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:src="@drawable/ocean"
android:scaleType="center"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:background="#ffffff"
android:scaleType="center"/></LinearLayout>
И тогда выглядит так:
3- Так могут родиться и другие идеи, например, эта
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
><ImageView
android:layout_width="300dp"
android:layout_height="80dp"
android:id="@+id/imageView1"
/><ImageView
android:layout_width="300dp"
android:layout_height="80dp"
android:id="@+id/imageView1"
android:src="@drawable/ocean"
/>
<ImageView
android:layout_width="300dp"
android:layout_height="80dp"
android:id="@+id/imageView1"
/> </LinearLayout>
Lokkingкак это
Другая возможность
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
><ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ocean"
android:id="@+id/imageView1"
android:scaleType="center"/><ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:background="#ffffff"
android:scaleType="center"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:background="#ffffff"
android:src="@drawable/ocean"
android:scaleType="center"/></LinearLayout>
Asмы видели, что вы можете использовать «скрытые пробелы» или «пробелы с цветом фона», чтобы быстро решить некоторые проблемы, очевидно, это не всегда возможно