Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 图像未填充ImageView中的宽度_Android_Android Imageview - Fatal编程技术网

Android 图像未填充ImageView中的宽度

Android 图像未填充ImageView中的宽度,android,android-imageview,Android,Android Imageview,将照片设置为ImageView并不像我预期的那样工作。它不能完全填满宽度。 这是我的代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout1" android:layout_width="match_parent" and

将照片设置为ImageView并不像我预期的那样工作。它不能完全填满宽度。 这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    android:orientation="horizontal" >

    <com.android.volley.toolbox.NetworkImageView
        android:id="@+id/imageCell"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:layout_margin="5dp"
        android:src="@drawable/unnamed" />

</LinearLayout>

我尝试了android:layout\u width=“wrap\u content”,但仍然没有改变

第一个图像没有完全显示。第二个是在portraid模式下,它是正常的。 谢谢。

尝试设置

android:scaleType="fitXY"

到您的imageView

我以前也做过,来自xml/java,但没有任何改变。我真的不明白为什么。试着删除android:adjustViewBounds=“true”android:layout\u margin=“5dp”nope:(。在将图像设置为imageView并缩放为FITXY和:width:512,height:320之后,我已经放置了一个sysout。因此,图像不小。问题不在这里,是使用viewpager。它看起来不正常,因为有一种方法“public float getPageWidth(int position)”,它返回一个介于0.0f和1.0f之间的浮点值。我不知道如何使用它,所以图像的宽度是否大于另一个图像并不重要。但是thx。您的回答是正确的。