首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >软键盘上升时如何使按钮保持在底部

软键盘上升时如何使按钮保持在底部
EN

Stack Overflow用户
提问于 2016-05-11 12:36:49
回答 10查看 8.1K关注 0票数 13

我有一个按钮在屏幕底部,我希望它保持下来,即使软键盘上升,但目前它上升软键盘。我试着把按钮对准底部,但没有成功。

下面是代码(按钮在id/activity_form_button_frame中):

代码语言:javascript
代码运行次数:0
运行
复制
<RelativeLayout>
     <RelativeLayout
        android:id="@+id/activity_form_button_frame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">
    <ImageButton
        android:id="@+id/activity_form_next_button"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/black"
        android:src="@drawable/next_btn_drawable"
        android:scaleType="fitCenter"
        android:padding="5dp"
        />
    <Button
        android:id="@+id/activity_form_sumbit_button"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/black"
        android:text="SUBMIT"
        android:textColor="@color/buttonBlue"
        android:visibility="gone"
        android:padding="15dp"
        style="@android:style/TextAppearance.Large"/>
    </RelativeLayout>

    <FrameLayout
        android:id="@+id/activity_form_fragmentcontainer"
        android:layout_below="@id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/activity_form_button_frame"/>

    </RelativeLayout>
EN

回答 10

Stack Overflow用户

回答已采纳

发布于 2016-05-11 12:45:31

AndroidManifest.xml中,将android:windowSoftInputMode="adjustPan"设置为您的活动。

像这样的

代码语言:javascript
代码运行次数:0
运行
复制
<activity
    android:windowSoftInputMode="adjustPan">

或:

代码语言:javascript
代码运行次数:0
运行
复制
<activity
    android:windowSoftInputMode="adjustPan|adjustResize">

也可以通过编程方式完成.

onCreate()方法中使用此代码:

代码语言:javascript
代码运行次数:0
运行
复制
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

检查一下这个是否是参考文献

票数 20
EN

Stack Overflow用户

发布于 2016-05-11 13:20:31

试试这个..。

代码语言:javascript
代码运行次数:0
运行
复制
<activity
android:windowSoftInputMode="adjustPan">
票数 3
EN

Stack Overflow用户

发布于 2016-05-11 13:24:06

尝尝这个

代码语言:javascript
代码运行次数:0
运行
复制
<activity
android:windowSoftInputMode="adjustPan">

或在代码中

代码语言:javascript
代码运行次数:0
运行
复制
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37162919

复制
相关文章

相似问题

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