簡體   English   中英

Android scrollview縮小imageview

[英]Android scrollview shrinks imageview

這是我的布局XML具有RelativelayoutScrollview : -

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <RelativeLayout
        android:id="@+id/layout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp" >

        <View
            android:id="@+id/separator1"
            android:layout_width="fill_parent"
            android:layout_height="3dp"
            android:background="@android:color/white" />

        <TextView
            android:id="@+id/title"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/separator1"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:text="Merry Xmas"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textStyle="bold" />

        <View
            android:id="@+id/separator2"
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/title"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:background="@android:color/white" />

        <ImageView
            android:id="@+id/image1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_below="@+id/separator2"
            android:scaleType="fitCenter" />

        <View
            android:id="@+id/separator3"
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/image1"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:background="@android:color/white" />

        <TextView
            android:id="@+id/text2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/separator3"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:text="Happy New Year"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textStyle="bold" />
    </RelativeLayout>
</ScrollView>

這是我的問題:

  • 如果刪除ScrollView標簽,則ImagView拉伸並填充寬度,這正是我想要的。
  • 如果添加ScrollView標記,由於某種原因,它將縮小ImagView

知道如何應用ScrollView並讓ImageView填滿寬度嗎?

您是否嘗試過設置RealtiveLayout來填充父級? 我也注意到有時RelativeLayout會縮小imageViews。 也許您可以嘗試使用LinearLayout代替。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM