Android软键盘Android开发Android技术知识

禁止Activity+ EditText 界面默认弹出键盘

2017-05-02  本文已影响250人  旺仔爸

在父级添加这两句话
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/dp48"
        android:background="@drawable/shape_white_top_bottom_line"
        android:orientation="horizontal"
        android:paddingLeft="@dimen/dp10"
        android:paddingRight="@dimen/dp10"
        android:descendantFocusability="beforeDescendants"
        android:focusableInTouchMode="true"
        >
        <EditText
            android:id="@+id/progress_add_subtitle"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.8"
            android:background="@null"
            android:gravity="right|center_vertical"
            android:hint="@string/progress_add_subtitle_input"
            android:imeOptions="actionNext"
            android:maxLength="15"
            android:textColor="@color/black_text"
            android:textColorHint="@color/gray_text_light"
            android:textSize="@dimen/text_normal"
            />

    </LinearLayout>

参考文章:
http://stackoverflow.com/questions/18295802/how-to-make-edittext-not-focused-when-creating-activity

上一篇下一篇

猜你喜欢

热点阅读