Android Study Notes (20)-the UI is blocked by the Input Method

Source: Internet
Author: User

1. In the Android system, after entering text in the text box, the operation button is blocked by the input method. You have to disable the input method to continue the operation. This is always the case by default, which is very troublesome.

2. So I checked some information and finally found the method.

Let's take a look at the code and effects:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical"    android:background="#ffffffff" >    <LinearLayout        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:orientation="horizontal"        android:paddingBottom="30dp" >        <Button            android:id="@+id/Date"            android:layout_weight="1"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:textSize="16dp"            android:gravity="center_vertical"            android:singleLine="true"            android:layout_marginTop="3dp"/>        <Button            android:id="@+id/Time"            android:layout_weight="1"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:textSize="16dp"            android:gravity="center_vertical"            android:singleLine="true"            android:layout_marginTop="3dp" />    </LinearLayout>    <EditText        android:id="@+id/mText"        android:layout_width="fill_parent"        android:layout_height="100px"        android:background="@drawable/shape"         android:textColor="#aa000000"        android:textSize="20dp"        android:gravity="top"        android:layout_margin="3dp"        android:paddingLeft="10dp"        android:paddingRight="10dp"/>    <LinearLayout        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:orientation="horizontal" >        <Button            android:id="@+id/set"            android:layout_weight="1"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:layout_gravity="bottom"            android:text="Set"            android:textSize="20dp"             />        <Button            android:id="@+id/discard"            android:layout_weight="1"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:layout_gravity="bottom"            android:text="Cancel"            android:textSize="20dp" />    </LinearLayout></LinearLayout>

It can be seen that this has been achieved to avoid the use of a soft keyboard to block the page.

Display process:

You do not need to change the local file, but modify the androidmanifest. xml file. Add one in the activity attribute:

<activity            android:name="com.ideal.studys.EditTime"            android:label="@string/app_name"             android:windowSoftInputMode="stateHidden|adjustResize" >        </activity>

Note that Android: layout_height = "100px" in textview is valid only when the subsequent size is modified according to the resolution of the hardware platform. This is not very clear.

Additional Parameters for Android: windowsoftinputmode =:

Value

Description

"Stateunspecified"

The keyboard status (whether it is hidden or visible) is not specified. The system selects an appropriate status or topic-dependent setting.

This is to set the default behavior of the software disk.

"Stateunchanged"

The keypad remains visible or hidden no matter what the last time it was, when the main window appears in front of it.

"Statehidden"

When the user selects the activity, the soft keyboard is hidden-that is, when the user is sure to navigate to the activity, instead of returning it because it leaves another activity.

"Statealwayshidden"

The keyboard is always hidden when the activity Main Window gets the focus.

"Statevisible"

The soft keyboard is visible when it is appropriate (when you navigate to the activity main window ).

"Statealwaysvisible"

When you select this activity, the soft keyboard is visible-that is, when you are sure to navigate to this activity, instead of returning it because it leaves another activity.

"Adjustunspecified"

It is not specified whether the activity main window is adjusted to set aside space for the soft keyboard, or whether the content of the window is visible to the current focus on the screen. The system automatically selects one of these modes, depending on whether the content of the window has any layout view that can scroll their content. If there is such a view, the window will be adjusted. This assumption can make the content of the scrolling window visible in a small area. This is the default behavior settings for the main window.

"Adjustresize"

The screen size of the main activity window is always adjusted to reserve space for the keyboard.

"Adjustpan"

The main window of the activity does not adjust the screen size to allow space on the keyboard. On the contrary, the content of the current window is automatically moved so that the current focus is not overwritten by the keyboard and the user can always see the part of the input content. This is usually not expected to adjust the size, because the user may close the soft keyboard to obtain interaction with the covered content

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.