android中的EditText的使用

一.android:windowSoftInputMode属性详解

【1】stateUnspecified:软键盘的状态并没有指定,系统将选择一个合适的状态或依赖于主题的设置
【2】stateUnchanged:当这个activity出现时,软键盘将一直保持在上一个activity里的状态,无论是隐藏还是显示
【3】stateHidden:用户选择activity时,软键盘总是被隐藏
【4】stateAlwaysHidden:当该Activity主窗口获取焦点时,软键盘也总是被隐藏的
【5】stateVisible:软键盘通常是可见的
【6】stateAlwaysVisible:用户选择activity时,软键盘总是显示的状态
【7】adjustUnspecified:默认设置,通常由系统自行决定是隐藏还是显示
【8】adjustResize:该Activity总是调整屏幕的大小以便留出软键盘的空间
【9】adjustPan:当前窗口的内容将自动移动以便当前焦点从不被键盘覆盖和用户能总是看到输入内容的部分

二.EditText的使用

需求:模仿ios的输入框效果,在键盘弹出来输入的时候,布局除去标题栏整体向上滑动

这里写图片描述

如果用ScrollView将中间的布局包裹,而底部的提交评价的view设置layout_alignParentBottom为ture,最后会被软键盘顶上来
最后只有将底部的view放在ScrollView包裹的LinearLayout里面,值得注意是:

  • 1.ScrollView只能包裹一个子布局
  • 2.当ScrollView的子布局想填满ScrollView时,使用”match_parent”是不管用的,必需为ScrollView设置:android:fillViewport=”true”。

然后将面试评价的布局设置成自增长就行了,这样底部的提交评价view就可以显示在屏幕最底部了

布局代码:
  • 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: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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值