【问题标题】:Android: How to align button to the bottom and above the keyboard when it is up?Android:如何在向上时将按钮与键盘底部和上方对齐?
【发布时间】:2013-06-06 18:41:28
【问题描述】:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
<EditText
    android:id="@+id/editTextTitle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/task_title"
    android:ems="10" >

    <requestFocus />
</EditText>

<RelativeLayout android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">
<Button
    android:id="@+id/buttonSeven"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="7" />

</RelativeLayout>

尝试对齐屏幕底部的几个按钮。但是,当键盘弹出时,我希望按钮向上移动到键盘上方。该怎么做?

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    在你的 AndroidManifest.xml 中添加这个属性: android:windowSoftInputMode="adjustResize"

    <activity 
                android:windowSoftInputMode="adjustResize"
                android:name="com.example.stackoverflow.SimpleActivity5" >
    

    【讨论】:

      【解决方案2】:

      您需要在清单中注释活动。请参阅the manifest documentation on attribute android:windowSoftInputMode,您需要指定android:windowSoftInputMode="adjustResize",以便在显示键盘时,将您的活动的视口调整为键盘上方的区域,嘿嘿!按钮重新出现。

      【讨论】:

        猜你喜欢
        • 2017-07-27
        • 2011-06-08
        • 2011-06-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-23
        • 1970-01-01
        相关资源
        最近更新 更多