首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >软件键盘调整Android上背景图像的大小

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

Stack Overflow用户
提问于 2010-11-27 01:38:44
回答 13查看 69.9K关注 0票数 141

每当出现软键盘时,它都会调整背景图像的大小。请参考下面的截图:

如你所见,背景有点挤。有没有人能解释为什么背景会改变大小?

我的布局如下:

代码语言:javascript
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/page_bg"
    android:isScrollContainer="false"
>
    <LinearLayout android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
    >
        <EditText android:id="@+id/CatName"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:inputType="textCapSentences"
            android:lines="1"
        />
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/save"
            android:onClick="saveCat"
        />
    </LinearLayout>
    <ImageButton
        android:id="@+id/add_totalk"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@null"
        android:src="@drawable/add_small"
        android:scaleType="center"
        android:onClick="createToTalk"
        android:layout_marginTop="5dp"
    />
</LinearLayout>
EN

回答 13

Stack Overflow用户

回答已采纳

发布于 2010-11-27 15:04:43

好的,我用下面的命令修复了它

代码语言:javascript
复制
android:windowSoftInputMode="stateVisible|adjustPan"

manifest文件中<Activity >标记内的条目。我认为这是由于在活动中使用了ScrollView造成的。

票数 198
EN

Stack Overflow用户

发布于 2011-05-02 11:46:35

只是为了补充一下。

如果你在你的活动上有一个列表视图,你需要在你的列表视图属性中添加这个android:isScrollContainer="false" ...

不要忘记在您的活动中将android:windowSoftInputMode="adjustPan"添加到您的清单xml中……

如果你们在布局中使用带有滚动视图的android:windowSoftInputMode="adjustUnspecified",那么你的背景仍然会被软键盘调整大小……

如果你使用"adjustPan“值来防止你的背景改变大小,那会更好。

票数 14
EN

Stack Overflow用户

发布于 2014-11-13 00:16:45

如果有人需要adjustResize行为,并且不希望调整其ImageView的大小,这里有另一个解决方法。

只需将ImageView放入带有ScrollView.fillViewport = trueScrollView => RelativeLayout中。

代码语言:javascript
复制
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <FrameLayout
            android:layout_width="100dp"
            android:layout_height="100dp">

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

        </FrameLayout>
    </RelativeLayout>
</ScrollView>
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4287473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档