Android scrollview中的图像不';不能正确显示
我发现在不同的设备上很好地显示图像有问题。 S3设备的示例,它们以我想要的方式显示: 然而,对于S6设备,图像显示太小,尤其是纵向图像。 任何人都知道如何解决这个问题,因为我试着使用体重、匹配父母等方法,但效果并不理想。 p、 当我把imageview放在scrollview上面时,有时工作得非常完美 下面是我当前的XMLAndroid scrollview中的图像不';不能正确显示,android,android-xml,android-scrollview,Android,Android Xml,Android Scrollview,我发现在不同的设备上很好地显示图像有问题。 S3设备的示例,它们以我想要的方式显示: 然而,对于S6设备,图像显示太小,尤其是纵向图像。 任何人都知道如何解决这个问题,因为我试着使用体重、匹配父母等方法,但效果并不理想。 p、 当我把imageview放在scrollview上面时,有时工作得非常完美 下面是我当前的XML <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns
<LinearLayout 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"
android:orientation="vertical"
>
<include
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ivEventInfoPoster"
android:src="@drawable/carfreeday"
android:scaleType="center"
android:contentDescription="@string/common_img_desc"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvEventInfoTitle"
android:paddingTop="5dp"
android:text="Title"
android:textSize="24sp"
android:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvEventInfoDesc"
android:text="Desc"
android:layout_marginTop="3dp"
android:textSize="16sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvEventInfoDate"
android:text="Date"
android:textSize="16sp"
android:layout_marginBottom="10dp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
您是否尝试过更新ImageView的版本
除了scaleType之外,您还可以设置ImageView的属性使用
ImageView
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ivEventInfoPoster"
android:src="@drawable/carfreeday"
android:scaleType="fitStart"
android:adjustViewBounds="true"
android:contentDescription="@string/common_img_desc"
/>
您是否尝试将android:adjustViewBounds=“true”添加到您的图像视图中?您是否有可用于不同屏幕大小的绘图功能,因为S3的屏幕分辨率为720 x 1280像素,S6为2560 x 1440。是的,这会让我的图像产生大量空白@NaviRamyle@EricB. 但是来自后端的数据因此图像大小是不可预测的。哦,然后尝试给它一个固定的高度,因为您正在使用ScrollView并添加android:scaleType=“fitXY”