Use of EditText in android

Keywords: Android iOS xml encoding

1. android: windowSoftInputModel property details

Meaning of each value:

[1] stateUnspecified: The state of the soft keyboard is not specified, and the system will choose an appropriate state or subject-dependent settings
[2] stateUnchanged: When this activity appears, the soft keyboard will remain in the last activity, whether hidden or displayed
[3] stateHidden: The soft keyboard is always hidden when the user selects activity
[4] stateAlwaysHidden: When the main window of the Activity gets focus, the soft keyboard is always hidden
[5] stateVisible: Soft keyboards are usually visible
[6] stateAlwaysVisible: The state that the soft keyboard always displays when the user selects activity
[7] adjustUnspecified: Default setting, usually hidden or displayed by the system at its own discretion
[8] AdjuResize: This Activity always resizes the screen to allow space for the soft keyboard
[9] AdjuPan: The contents of the current window will move automatically so that the current focus is never covered by the keyboard and the user can always see the part of the input

2. Use of EditText

Requirements: mimic the ios input box effect, the layout slides up without the title bar when the keyboard pops up to enter

If you wrap the middle layout with ScrollView, and the view submitting the evaluation at the bottom sets layout_alignParentBottom to true, it will end up on top of the soft keyboard

Finally, only the bottom view is placed inside the inearLayout wrapped in ScrollView, which is worth noting:

  • 1.ScrollView can only wrap one sublayout
  • 2. When ScrollView's sublayouts want to fill ScrollView, using "match_parent" is useless and must be set for ScrollView: android:fillViewport="true".

Then set the layout of the interview evaluation to grow from scratch so that the submit evaluation view at the bottom of the screen is displayed at the bottom

Layout code:

  • manifest:
 <activity
    android:name=".view.activity.InterviewAssessActivity"
    android:screenOrientation="portrait"
    android:windowSoftInputMode="adjustResize|stateHidden" />
  • layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical"
    tools:context="com.recruit.cymobi.view.activity.InterviewAssessActivity">

    <com.recruit.cymobi.view.widget.TitleBarView
        android:id="@+id/titleBar"
        style="@style/TitleBarDefault"
        app:TitleBar_center_text="@string/interview_assess_title"
        app:TitleBar_left_Drawable="@drawable/icon_back" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/titleBar"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/ll_ver"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white"
                android:orientation="vertical"
                android:paddingBottom="14dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="12dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/tv_name"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:lines="1"
                        android:text="Android Development Engineer"
                        android:textColor="@color/c_333333"
                        android:textSize="16sp" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1" />

                    <TextView
                        android:id="@+id/tv_money"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="12k-13k"
                        android:textColor="#FF4700"
                        android:textSize="15sp" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/tv_address"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Wuhan|Wuchang District|"
                        android:textColor="@color/c_888888"
                        android:textSize="12sp" />

                    <TextView
                        android:id="@+id/tv_experience"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Unlimited experience"
                        android:textColor="@color/c_888888"
                        android:textSize="12sp" />

                    <TextView
                        android:id="@+id/tv_education"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="|Undergraduate"
                        android:textColor="@color/c_888888"
                        android:textSize="12sp" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1" />

                    <TextView
                        android:id="@+id/tv_time"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:lines="1"
                        android:text="12-18"
                        android:textColor="@color/c_888888"
                        android:textSize="12sp" />
                </LinearLayout>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="horizontal">

                    <ImageView
                        android:id="@+id/remand_img"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:layout_centerVertical="true"
                        android:layout_marginEnd="10dp"
                        android:layout_marginRight="10dp"
                        android:layout_marginTop="10dp"
                        android:scaleType="centerCrop"
                        android:src="@drawable/image_null" />

                    <TextView
                        android:id="@+id/tv_groupname"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:layout_toEndOf="@+id/remand_img"
                        android:layout_toRightOf="@id/remand_img"
                        android:ellipsize="end"
                        android:lines="1"
                        android:text="Wuhan Monkey Technology Co., Ltd."
                        android:textColor="#555555"
                        android:textSize="14sp" />

                    <TextView
                        android:id="@+id/tv_groupdescribe"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/tv_groupname"
                        android:layout_marginTop="5dp"
                        android:layout_toEndOf="@+id/remand_img"
                        android:layout_toRightOf="@+id/remand_img"
                        android:text="No Financing Required | 50-150 | Living Services"
                        android:textColor="#AAAAAA"
                        android:textSize="12sp" />
                </RelativeLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="4dp"
                android:background="@color/white"
                android:orientation="vertical"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="10dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/overall_rating"
                    android:textColor="@color/c_333333"
                    android:textSize="16sp" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="20dp"
                        android:text="@string/job_description"
                        android:textColor="@color/c_333333"
                        android:textSize="14sp" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_yes" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_yes" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_yes" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_no" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="20dp"
                        android:text="@string/interviewer_performance"
                        android:textColor="@color/c_333333"
                        android:textSize="14sp" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_yes" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_yes" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_yes" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_no" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="20dp"
                        android:text="@string/company_environment"
                        android:textColor="@color/c_333333"
                        android:textSize="14sp" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_yes" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_yes" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_yes" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:src="@drawable/icon_star_no" />

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginTop="4dp"
                android:layout_weight="1"
                android:orientation="vertical"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="10dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/interview_assess"
                    android:textColor="@color/c_333333"
                    android:textSize="16sp" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="160dp"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/bg_edit_resume"
                    android:gravity="top"
                    android:hint="@string/interview_assess_des"
                    android:padding="10dp"
                    android:textColorHint="#bcbcbc"
                    android:textSize="13sp" />

            </LinearLayout>

            <LinearLayout
                android:id="@+id/ll_comit_assess"
                android:layout_width="match_parent"
                android:layout_height="52dp"
                android:background="@color/white"
                android:orientation="horizontal"
                android:paddingBottom="5dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="5dp">

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:background="@null"
                    android:drawableLeft="@drawable/icon_anonymous_no"
                    android:gravity="center"
                    android:padding="13dp"
                    android:text="@string/anonymous"
                    android:textColor="@color/c_333333"
                    android:textSize="14sp" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/shape_button_finish"
                    android:gravity="center"
                    android:text="@string/commit_assess"
                    android:textColor="@color/white"
                    android:textSize="16sp" />

            </LinearLayout>

        </LinearLayout>

    </ScrollView>

</RelativeLayout>

Posted by JakeTheSnake3.0 on Thu, 16 May 2019 00:46:14 -0700