Java 如何将imageview设置为占用屏幕宽度?
我想要一个占据屏幕(或布局)宽度的imagview,但视图周围似乎有填充物,这阻止了我这样做 使用相应的xml:Java 如何将imageview设置为占用屏幕宽度?,java,android,Java,Android,我想要一个占据屏幕(或布局)宽度的imagview,但视图周围似乎有填充物,这阻止了我这样做 使用相应的xml: <?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" and
<?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" android:weightSum="1">
<ImageView android:src="@drawable/icon" android:background="@null"
android:layout_height="106dp" android:id="@+id/imageView1"
android:layout_weight="0.59" android:layout_width="match_parent"></ImageView>
</LinearLayout>
尝试更改:
android:layout_width="match_parent"
致:
尝试更改:
android:layout_width="match_parent"
致:
填充物来自android图标上的透明区域。
只需删除未使用的透明区域或使用其他图像。填充来自android图标上的透明区域。
只需删除未使用的透明区域或使用另一个图像。将版面宽度和高度设置为填充
<ImageView android:src="@drawable/icon" android:background="@null"
android:layout_height="fill_parent" android:id="@+id/imageView1"
android:layout_weight="1" android:layout_width="fill_parent"></ImageView>
将版面宽度和高度设置为填充父项
<ImageView android:src="@drawable/icon" android:background="@null"
android:layout_height="fill_parent" android:id="@+id/imageView1"
android:layout_weight="1" android:layout_width="fill_parent"></ImageView>
没有这样的运气;似乎没有任何影响。@Sheldon您在两种设置中都更改了吗?LinearLayout和imageView?fill_parent和match_parent是同一件事没有这样的运气;似乎没有任何影响。@Sheldon您在两种设置中都更改了吗?LinearLayout和imageView?fill\u parent和match\u parent是相同的内容使用android:scaleType=“fitXY”用于imageView。使用android:scaleType=“fitXY”用于imageView。