android - ScrollView 套 ImageView 显示异常
巴扎黑
巴扎黑 2017-04-17 17:38:28
0
2
486
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/img_background"
            android:scaleType="fitXY"/>

    </ScrollView>
    
</CoordinatorLayout>   

为了解决键盘弹出时背景图不被压缩才这样布局,可是里面的 ImageView中显示的图片却没有按照规定的大小显示,而是按照图片本身的尺寸显示,导致了在不同分辨率下图片显示不同(即便高度写死如200dp 还是按照图片本身的尺寸显示),所以在Nexus6p这种高分辨率的机型上底部会有未被 ImageView 覆盖到的区域,显示为白色。求解~

巴扎黑
巴扎黑

répondre à tous(2)
PHPzhong

Lorsque ScrollView n'a pas fillViewport="true", les éléments à l'intérieur (tels que LinearLayout) seront calculés en fonction de wrap_content (qu'il ait ou non "match_parent")

Peter_Zhu

Dans le fichier Mainfest.xml, écrivez android:windowSoftInputMode="adjustPan" dans cette activité pour éviter que l'interface ne soit encombrée par le clavier contextuel.

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal