首先,您需要在LinearLayout声明中使用“ match_parent”,而不要使用“ fill_parent”,您可以选中“正式文档”在这里[https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#MATCH_PARENT]另一个观察结果是,您需要将ImageView作为孩子使用,然后使用ImageView应该是自动关闭的。 这个表示应以“ />”结尾。然后,让我向您展示一些快速的想法:1-作为自然方式
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:src="@drawable/ocean" android:scaleType="center"/>
然后看起来像
2-您可以快速即兴创作
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:scaleType="center"/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:src="@drawable/ocean"
android:scaleType="center"/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:background="#ffffff"
android:scaleType="center"/>
然后看起来像
3-其他想法可能以这种方式诞生,例如,这个想法
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:layout_width="300dp"
android:layout_height="80dp"
android:id="@+id/imageView1"
/>
android:layout_width="300dp"
android:layout_height="80dp"
android:id="@+id/imageView1"
android:src="@drawable/ocean"
/>
android:layout_width="300dp"
android:layout_height="80dp"
android:id="@+id/imageView1"
/>
看起来像这样
其他可能性
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ocean"
android:id="@+id/imageView1"
android:scaleType="center"/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:background="#ffffff"
android:scaleType="center"/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:background="#ffffff"
android:src="@drawable/ocean"
android:scaleType="center"/>
正如我们所看到的,您可以使用“隐藏空间”或“具有背景色的空间”快速解决一些问题,显然,这并不总是可能的