我为我的应用程序工作背景,但是当我打开键盘时图像调整大小。相关布局背景在键盘打开时调整大小
我从adjustPan等听到过,但它并没有工作。 getWindow.setBackground也不能工作,因为我在一个片段。
如果我设置了Windows背景它可以工作,但是当我回去时背景仍然存在。
屏幕:
Correct screen
Incorrect screen
我为我的应用程序工作背景,但是当我打开键盘时图像调整大小。相关布局背景在键盘打开时调整大小
我从adjustPan等听到过,但它并没有工作。 getWindow.setBackground也不能工作,因为我在一个片段。
如果我设置了Windows背景它可以工作,但是当我回去时背景仍然存在。
屏幕:
Correct screen
Incorrect screen
的原因似乎是,你使用android:windowSoftInputMode="adjustResize"
软键盘打开时调整大小您的活动。这就是你想要的,但是背景图像总是调整大小以适应整个元素。不要使用背景,请在布局的底部放置一个ImageView
,并将图像放在正确的android:scaleType
处,这样可以防止纵横比丢失。
与scaleType="fitStart"
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="280dp"
android:layout_height="match_parent"
android:background="@android:color/white"
android:paddingTop="8dp">
<ImageView
android:id="@+id/img_background"
android:src="@drawable/background"
android:scaleType="fitStart"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<include layout="@layout/content"/>
</FrameLayout>
添加ImageView的尝试此解决方案[链接](http://stackoverflow.com/a/4737265/3395978) – Marlen
你有一个例子,因为我didn't了解它是如何工作的:C – flectiondev
在FrameLayout中包装你的视图,设置你的背景并调整你添加到FrameLayout的内容。 – Marlen