Android 为什么赢了';";“完成”;当我的手机垂直时,此编辑文本的按钮显示
我有这个Android 为什么赢了';";“完成”;当我的手机垂直时,此编辑文本的按钮显示,android,xml,android-edittext,landscape,portrait,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
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"/>
当手机垂直时,我希望“完成”按钮的显示方式与手机水平时的显示方式相同
在横向中,编辑EditText
占据整个屏幕;没有任何应用程序UI可见或可用于滚动/点击。这就是为什么“完成”按钮仅在横向显示,以便用户可以退出编辑模式并返回到应用程序UI。如果在当前视图之后还有其他EditText
视图,则按钮将显示“下一步”
在纵向中,应用程序UI可见,因此此按钮不显示。相反,用户可以在编辑后直接在应用程序UI中执行操作
我还希望在按下返回键时将光标向下移动一行
您的意思是插入新行,然后将光标向下移动到新行吗?如果是这样,在
android:inputType
中指定textMultiLine
应该可以启用此行为。当您点击回车键时会发生什么情况?当手机处于水平状态时,您将处于一种称为“提取视图”的特殊模式,键盘将绘制整个屏幕。键盘就是这样画的。在纵向视图中,您不在“提取”视图中,因此它不会显示该ui。请注意,这种行为因键盘而异,许多键盘选择不执行提取视图,尤其是在平板电脑上
我不认为有办法强迫它显示肖像的提取视图-键盘决定是否输入它,我不知道有哪个键盘可以为肖像显示。如果你想要这个用户界面,你必须自己从头开始做。发布整个布局文件。我不确定实际情况是否如此。您提到的“提取视图”适用于IME的全屏模式,其中键盘不仅占据屏幕的全宽,而且几乎占据屏幕的全高,并且显示的编辑文本由IME生成。从OP的帖子中不清楚“完成”按钮是他们布局的一部分还是自动创建的。除非OP显示完整的布局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>