如何保持背景图像的大小时,软键盘显示 [英] How to keep background image size when software keyboard show

查看:125
本文介绍了如何保持背景图像的大小时,软键盘显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在软键盘显示,它会调整我的布局,从而挤压背景影像。我的问题基本上是这个问题,这是一个非常好的方式解释重复的:

When the software keyboard shows, it resizes my layout and thus squeezes the background image together. My question is basically a duplicate of this question, which is explained in a very good way:

<一个href="http://stackoverflow.com/questions/4287473/android-soft-keyboard-resizes-background-image">Android:软键盘调整大小,背景图片

不过,这个问题被关闭时,他们发现了一个黑客来解决它。我不能使用这个技巧。我的整个布局里面滚动型的,我需要能够正确地使用这种滚动型在任何时候。使用Android:windowSoftInputMode =stateVisible | adjustPan的用户将无法向下滚动,看到而键盘显示在屏幕的底部,因为布局将部分键盘背后存在。因此,解决方案是不能接受的箱。有没有更好的办法了吗?

However, that question was closed when they found a hack to solve it. I cannot use this hack. My entire layout is inside a ScrollView, and I need to be able to use this scrollview properly at all times. By using android:windowSoftInputMode="stateVisible|adjustPan" the user will not be able to scroll down and see the bottom of the screen while the keyboard is showing, since the layout will partly exist behind the keyboard. Thus the solution is unacceptable to me. Are there any better solutions out there?

干杯,

推荐答案

在核心的天盗号我终于成功地构建解决方案,以便推进它实际上可能伤害读它。我把一个ImageView的用滚动视图后面的背景,并设置scaleType =黑客帝国,因此它不会收缩键盘时显示。

After days of hardcore hacking I finally managed to construct a solution so advanced it might actually hurt to read it. I place an ImageView with the background behind the scrollview, and set scaleType="matrix" so it does not shrink when the keyboard is shown.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/black"
    >
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/mah_kewl_background"
        android:scaleType="matrix"
        />
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"
        >
        <RelativeLayout
            android:id="@+id/smsLayout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="PLUNX"
                />
        </RelativeLayout>
    </ScrollView>
</RelativeLayout>

这篇关于如何保持背景图像的大小时,软键盘显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆