打开软键盘时不要缩小图像视图或背景

时间:2018-09-29 09:11:16

标签: android android-constraintlayout

打开键盘时,背景会缩小。看看Quote:

enter image description here

活动有android:windowSoftInputMode="adjustResize"

这是我的布局:

<android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@drawable/background"
            android:scaleType="center"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <FrameLayout
            android:id="@+id/container"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent" />

    </android.support.constraint.ConstraintLayout>
</layout>

如何防止这种情况?

1 个答案:

答案 0 :(得分:0)

尝试一下

在您的活动Manifest中,将活动视图声明为

android:windowSoftInputMode="adjustResize|stateHidden"

然后遵循以下代码:

Bitmap bmImg; // Load a bitmap into bmImg 
BitmapDrawable background = new BitmapDrawable(bmImg); 
background.setGravity(Gravity.TOP); 
this.setBackgroundDrawable(background);