簡體   English   中英

顯示軟鍵盤時調整EditText的大小

[英]Resize the EditText when softkeyboard gets displayed

顯示軟鍵盤時如何調整EditText的大小? 出於兼容性原因(不同的屏幕尺寸和密度),我們是否可以將EditText的大小調整為一個值,使其在軟鍵盤上方為“ 20dp”,否則整個屏幕都可以滾動? 在SE上閱讀了許多有關使用螺母的帖子,這些螺母對我不起作用。

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:imeOptions="flagNoExtractUi"可能會對您有所幫助。 有關imeOptions更多信息,您可以在這里閱讀

希望能幫助到你

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM