【问题标题】:Resize the EditText when softkeyboard gets displayed显示软键盘时调整 EditText 的大小
【发布时间】:2012-05-28 16:24:28
【问题描述】:

显示软键盘时如何调整 EditText 的大小?出于兼容性原因(不同的屏幕尺寸和密度),我们是否可以将 EditText 调整为软键盘上方的“20dp”或整个屏幕可滚动的值?在 SE 上阅读许多关于使用 nut 的帖子,但它们对我没有用。

main.xml 文件如下:

<?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:layout_weight="1.04" >
  <Button
            android:id="@+id/Save"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="15dp"
            android:layout_marginTop="16dp"
            android:layout_marginBottom="20dp"
            android:textColor="#ffffff"
            android:text="@string/SaveButton" />

        <EditText
            android:id="@+id/NoteTextBox"
            android:layout_width="fill_parent"
            android:layout_height="180dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/Save"
            android:layout_marginTop="20dp"
            android:ems="10"
            android:textColor="#ffffff"
            android:inputType="text"
            android:singleLine="false" >

            <requestFocus />

        </EditText>

    </RelativeLayout>

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    尝试使用android:imeOptions="flagNoExtractUi",它可能会对您有所帮助。 更多关于imeOptions你可以阅读here

    希望对你有帮助

    【讨论】:

    • 所以看看here我希望它会帮助你。
    猜你喜欢
    • 2019-03-19
    • 2012-09-29
    • 2015-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-09
    • 1970-01-01
    相关资源
    最近更新 更多