scrollview中的图像无法正常显示

时间:2015-11-13 03:55:27

标签: android android-xml android-scrollview

我有问题在不同的设备上很好地显示图像。 S3 Device的示例,它们以我想要的方式显示: S3

然而,S6 Device,图像显示太小,尤其是肖像图像。 S6

任何人都知道如何解决这个问题,因为我试图使用体重,匹配父母等并没有真正解决这个问题。 附:当我将我的imageview放在scrollview上方时,有时候工作非常完美。

以下是我当前的XML

<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>

2 个答案:

答案 0 :(得分:3)

使用<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" />

尝试此操作
class PongActor extends Actor with ActorLogging {
  import PongActor._

  def receive = {
    case PingActor.PingMessage(text) => 
      log.info("In PongActor - received message: {}", text)
      sender() ! PongMessage("pong")
  } 
}

object PongActor {
  val props = Props[PongActor]
  case class PongMessage(text: String)
}

答案 1 :(得分:0)

您是否尝试更新ImageView的scaleType

除了scaleType,您还可以设置ImageView的adjustViewBounds属性