Android自定义带标题和可清除功能的EditText
Users of your library will need add the jitpack.io repository:
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
and:
dependencies {
compile 'com.github.zhouchupen:TextClearableEditText:v1.1'
}
Note: do not add the jitpack.io repository under buildscript
If you add a sample app to the same repo then your app needs to depend on the library. To do this in your app/build.gradle add a dependency in the form:
dependencies {
compile project(':library')
}
where 'library' is the name of your library module.
You may need this to use the edittext. Put this into your xml file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.scnu.zhou.widget.TextClearableEditText
android:id="@+id/et_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="用户名"
app:hint="请输入用户名"
app:lineColor="#97CC00"
app:singleline="true"
android:layout_marginTop="15dp">
</com.scnu.zhou.widget.TextClearableEditText>
<com.scnu.zhou.widget.TextClearableEditText
android:id="@+id/et_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="密码"
app:hint="请输入密码"
app:lineColor="#97CC00"
app:singleline="true"
app:password="true"
android:layout_marginTop="15dp">
</com.scnu.zhou.widget.TextClearableEditText>
</LinearLayout>
where ‘lineColor’ is the color of the underline, and you can set 'password' as true to make the input type of edittext 'password'.