android自定义控件(仿天猫搜索框)

天猫搜索框效果

仿天猫的搜索框做了一个控件

ChooseEditText

项目放在github上
Github地址


youtube上查看示例
如何使用
=====
Gradle Dependency

compile 'com.chooseedittext:library:1.0.0'

具体用法

布局中引用
Declare it inside your layout XML file like this:

    <com.library.ChooseEditText
        android:id="@+id/chooseedittext"
        app:cet_Hint="Input content "
        app:cet_TextSize="10sp"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_margin="4dp">
    </com.library.ChooseEditText>

输入框中添加一个Tag方法

String text="Nike";
chooseEditText.addItem(text);

监听输入变化

chooseEditText.setOnChooseEditTextListener(new OnChooseEditTextListener() {
            @Override
            public void onTextChangeed(String text) {
            // do something,做自己的处理
                tvResult.setText(text);
            }
        });
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容