为什么不会完成"完成"当我的手机处于垂直状态时,按钮会显示此EditText

时间:2015-02-25 00:51:46

标签: android xml android-edittext landscape portrait

我有EditText

<EditText
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/inputText"
    android:inputType="textCapCharacters|textMultiLine"
    android:hint="@string/input_text_hint"
    android:gravity="top|left"/>

当我在手机水平时选择它时,我看到了: enter image description here

但是当我在手机垂直时选择它时,我看到了: enter image description here

当手机处于垂直状态时,我希望“完成”按钮显示为手机水平时的状态。

我还希望返回键在按下时将光标向下移动一行。

我该怎么做?

修改

如果有人想知道...... {/ p>,请activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
    android:weightSum="18"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="13">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/inputText"
            android:inputType="textCapCharacters|textMultiLine"
            android:hint="@string/input_text_hint"
            android:gravity="top|left"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2">

        <Button
            android:background="@drawable/main_button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="@string/big_button"
            android:id="@+id/bigButton"
            android:textSize="68sp"
            android:focusableInTouchMode="false"
            android:fontFamily="sans-serif-black"
            style="@style/button_text"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="3"
        android:clickable="false"></LinearLayout>
</LinearLayout>

2 个答案:

答案 0 :(得分:1)

  

当手机处于垂直状态时,我想要&#34; DONE&#34;按钮显示为手机水平时的状态。

在横向广告中,编辑EditText会占据整个屏幕;没有任何应用UI可见或可用于滚动/点击。这就是&#34; DONE&#34;按钮仅以横向显示,以便用户可以退出编辑模式并返回到应用程序UI。如果您在当前视图后面有其他EditText个视图,则该按钮将显示&#34; NEXT&#34;。

在纵向中,应用程序UI可见,因此不显示此按钮。相反,用户可以在编辑后直接在应用UI中执行操作。

  

我还希望返回键在按下时将光标向下移动一行。

您的意思是插入换行符,然后将光标向下移动到新行吗?如果是这样,您在textMultiLine中指定android:inputType应启用此行为。点击回车键会发生什么?

答案 1 :(得分:1)

当手机处于水平状态时,您将进入名为&#34;提取视图&#34;的特殊模式。键盘绘制整个屏幕的位置。键盘是如何绘制它的。在纵向中,您不在提取视图中,因此它不会显示该ui。请注意,此行为因键盘而异,许多键盘选择不提取视图,尤其是在平板电脑上。

我认为有一种方法可以强制它显示纵向提取视图 - 键盘决定是否输入它,而且我不知道任何用于肖像的键盘。如果你想要那个UI,你必须自己从头开始。