android 搜索框(一)
16lz
2021-01-26
最开始做搜索框的时候,还以为android系统中的搜索框是自己搭的一个layout,折腾了半天,自己用ImageView,AutoCompleteTextView,ImageButton做了个形似的界面,效果还不错呢,不信看看下面的图片,哈哈,当时超高兴啊:
xml配置如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffffff"
>
<TableLayout
android:stretchColumns="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<ImageView
android:id="@+id/ltpic"
android:layout_marginTop="15px"
android:layout_marginLeft="10px"
android:layout_marginRight="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="http://qiangwei27.blog.163.com/blog/@drawable/smile"/>
<AutoCompleteTextView
android:id="@+id/ltsearch"
android:singleLine ="true"
android:text="@string/hello"
android:selectAllOnFocus="true"
android:completionThreshold="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:dropDownWidth="fill_parent"
android:dropDownHeight="wrap_content"
/>
<ImageButton
android:id="@+id/imgbtnsearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="http://qiangwei27.blog.163.com/blog/@drawable/smile"/>
</TableRow>
</TableLayout>
</LinearLayout>
可是后来发现,自己做的这个编辑框,虽然可以保存历史关键字,但是做输入关键字联想匹配时会很痛苦,后来又遇到另一个更更痛苦的事:就是全屏手写时,后面的那个搜索按钮无法点击(全屏手写时点击那个按钮,默认是画了一个点上去),痛苦了一阵子以后(痛苦也没办法,项目还得继续啊,不然那个帅帅的项目经理天天来催,我更头疼^_^),觉得android所有手机的搜索框都很一致,应该有自己一个搜索控件,所以开始找这个搜索的控件,总算没有白折腾,原来真有这么个东西,唉,这个悔啊,早知道我费那么大劲自己搭个界面干嘛啊,费力不讨好,还得重新来过。。。。
(待续啊///) 评论这张 转发至微博 转发至微博
xml配置如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffffff"
>
<TableLayout
android:stretchColumns="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<ImageView
android:id="@+id/ltpic"
android:layout_marginTop="15px"
android:layout_marginLeft="10px"
android:layout_marginRight="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="http://qiangwei27.blog.163.com/blog/@drawable/smile"/>
<AutoCompleteTextView
android:id="@+id/ltsearch"
android:singleLine ="true"
android:text="@string/hello"
android:selectAllOnFocus="true"
android:completionThreshold="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:dropDownWidth="fill_parent"
android:dropDownHeight="wrap_content"
/>
<ImageButton
android:id="@+id/imgbtnsearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="http://qiangwei27.blog.163.com/blog/@drawable/smile"/>
</TableRow>
</TableLayout>
</LinearLayout>
可是后来发现,自己做的这个编辑框,虽然可以保存历史关键字,但是做输入关键字联想匹配时会很痛苦,后来又遇到另一个更更痛苦的事:就是全屏手写时,后面的那个搜索按钮无法点击(全屏手写时点击那个按钮,默认是画了一个点上去),痛苦了一阵子以后(痛苦也没办法,项目还得继续啊,不然那个帅帅的项目经理天天来催,我更头疼^_^),觉得android所有手机的搜索框都很一致,应该有自己一个搜索控件,所以开始找这个搜索的控件,总算没有白折腾,原来真有这么个东西,唉,这个悔啊,早知道我费那么大劲自己搭个界面干嘛啊,费力不讨好,还得重新来过。。。。
(待续啊///) 评论这张 转发至微博 转发至微博
更多相关文章
- android email 邮件转发 附件不能转发问题的解决
- android 布局之ConstraintLayout的使用
- 自定义控件SettingItemView
- layout 布局
- Android(安卓)----可伸缩的控件
- Android(安卓)自定义控件之第二讲:TypedArray 详解
- android自定义控件基础
- Android(安卓)中自定义控件和属性
- 卷二 Dalvik与Android源码分析 第二章 进程与线程 2.2 Dalvik线