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

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

问题描述

当软件键盘显示时,它会调整我的布局大小,从而将背景图像压缩在一起.我的问题基本上是这个问题的重复,解释的很好:

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:

软件键盘在 Android 上调整背景图像的大小

但是,当他们找到解决问题的技巧时,这个问题就被关闭了.我不能使用这个黑客.我的整个布局都在 ScrollView 内,我需要能够始终正确使用此滚动视图.通过使用 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="matrix" 使其在显示键盘时不会缩小.

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天全站免登陆