Android 如何将图像设置为拉伸并填充屏幕?(屏幕分为两部分)
所以,我有一个分为两部分的屏幕。在屏幕的上半部分我有一个图像,在下半部分我有一个文本。无论发生什么,我都无法让我的图像正确地填充屏幕。它总是以图像顶部或侧面的空白结束(如下图所示):,。如果有人能帮我解决这件事,我将不胜感激Android 如何将图像设置为拉伸并填充屏幕?(屏幕分为两部分),android,css,Android,Css,所以,我有一个分为两部分的屏幕。在屏幕的上半部分我有一个图像,在下半部分我有一个文本。无论发生什么,我都无法让我的图像正确地填充屏幕。它总是以图像顶部或侧面的空白结束(如下图所示):,。如果有人能帮我解决这件事,我将不胜感激 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/flag"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView
android:id="@+id/population"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
/>
</LinearLayout>
应该有用。您可以找到scaleType的其他可能值,我尝试在其上使用align和gravity,但没有成功。我没有使用scaleType。你能为你的版面发布代码吗?我编辑了帖子,也发布了版面代码,先生。非常感谢,先生。它同时适用于android:scaleType=“centerCrop”和android:scaleType=“fitXY”。我完全忘了这件事。@Stellianteodor不客气。你可以把问题标记为已回答。当做
<ImageView
android:id="@+id/flag"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:layout_weight="1"/>