ScrollView内的ImageView(Android)

3

我似乎无法将我的imageView设置为填满按钮的整个空间(视图)。我有一个背景为白色的按钮。

请查看我的示例

enter image description here

我的代码:

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom" >

            <ScrollView
                android:id="@+id/scroll"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">

                <RelativeLayout
                    android:id="@+id/relativeLayout1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                     <ImageView
                 android:id="@+id/imageView21"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:scaleType="centerCrop"
                 android:src="@drawable/bg_shkaf" />

                    </RelativeLayout>

    </ScrollView>
</RelativeLayout>

我同意@Tufan的观点,请发布更多细节... - Aspicas
2
你尝试过设置缩放类型为“fitXY”吗? - Haresh Chhelana
1
@ShivamVerma 他/她已经使用了 android:scaleType="centerCrop" - Aspicas
那么,他/她最好阅读一下评论。 - Shivam Verma
@ShivamVerma 好的,抱歉我没有看评论。 - Aspicas
@HareshChhelana fitXY 不起作用。 - mzb86604
1个回答

3

使用 android:fillViewport="true" 来为滚动视图填充,将 ImageView 的比例类型更改为 android:scaleType="fitXY"

<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="bottom" >

                <ScrollView
                    android:id="@+id/scroll"
                    android:fillViewport="true"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent">

                    <RelativeLayout
                        android:id="@+id/relativeLayout1"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >

                         <ImageView
                     android:id="@+id/imageView21"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
                     android:scaleType="fitXY"
                     android:src="@drawable/bg_shkaf" />

                        </RelativeLayout>



        </ScrollView>
    </RelativeLayout>

@mzb86604,如果您的声望足够高,请投赞成票 :) - Cyanotis

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接