我想在活动之上显示一个总是填满屏幕宽度的图像。如果我将其宽度设置为与父级及其高度匹配以包装内容,则在较大屏幕上的图像侧面会出现白色条纹。如何使此图像始终水平填满屏幕?
我的xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/hello_world"
android:src="@drawable/tbbt" />
</RelativeLayout>
提前致谢。
答案 0 :(得分:1)
更改imageview以适应整个屏幕宽度
android:scaleType="fitXY"
或
android:scaleType="centerCrop"