美文网首页
editText不自动获取焦点

editText不自动获取焦点

作者: 码圣 | 来源:发表于2021-03-19 11:20 被阅读0次

在editText的父控件中加入这两个属性

 android:focusable="true"
            android:focusableInTouchMode="true"

比如

<LinearLayout
            android:focusable="true"
            android:focusableInTouchMode="true"

            android:gravity="center_vertical"
            android:layout_marginTop="26dp"

            android:background="@drawable/shape_search_bg"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <ImageView
                android:layout_marginTop="8dp"
                android:layout_marginBottom="8dp"
                android:layout_marginLeft="13dp"
                android:layout_width="21dp"
                android:layout_height="21dp"
                android:src="@drawable/search">

            </ImageView>
            <EditText
                android:id="@+id/etSearch"
                android:background="@null"
                android:layout_marginLeft="11dp"
                android:textSize="15sp"
                android:textColorHint="#737373"
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:hint="搜索你喜欢的视频">

            </EditText>
        </LinearLayout>

相关文章

网友评论

      本文标题:editText不自动获取焦点

      本文链接:https://www.haomeiwen.com/subject/pndvcltx.html