EditText 去掉下划线 仿微信边框 selector

来源:互联网 发布:gtp手机吉他谱软件 编辑:程序博客网 时间:2024/05/15 13:43

EditText 去掉下划线 仿微信边框 selector

  • 仿微信边框 selector

    <?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">     <item>        <shape>            <corners android:radius="3dp"/>            <padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp"/>            <solid android:color="#fff"/>            <stroke android:width="0.5dp" android:color="#999999"/>        </shape>    </item></selector>
  • 自定义EditText 去掉下划线

    public class CusTomLineEditText extends android.support.v7.widget.AppCompatEditText {    private Paint mPaint;    public CusTomLineEditText(Context context) {        this(context, null);    }    public CusTomLineEditText(Context context, AttributeSet attrs) {        this(context, attrs, 0);    }    public CusTomLineEditText(Context context, AttributeSet attrs, int defStyleAttr) {        super(context, attrs, defStyleAttr);        mPaint = new Paint();        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);        mPaint.setStrokeWidth((float) 6.0);        mPaint.setColor(getResources().getColor(R.color.custom_color));    }    @Override    protected void onDraw(Canvas canvas) {        super.onDraw(canvas);        canvas.drawLine(0, this.getHeight() - 1, this.getWidth() - 1, this.getHeight()-1, mPaint);    }}
  • xml资源文件

     <com.hr.deanoffice.ui.view.CusTomLineEditText    android:id="@+id/btn_pressed_et"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:layout_centerVertical="true"    android:layout_gravity="center_vertical"    android:background="@null"    android:hint="@string/message_edit"    android:maxLines="4"    android:textColor="@android:color/black"    android:textSize="16sp" />
  • 底部drawableBottom

     <EditText    android:id="@+id/btn_pressed_et"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:layout_gravity="center_vertical"    android:background="@null"    android:drawableBottom="@drawable/edit_style_shape"    android:drawablePadding="3dp"    android:hint="@string/message_edit"    android:maxLines="4"    android:paddingBottom="5dp"    android:paddingTop="8dp"    android:textColor="@android:color/black"    android:textSize="16sp" />
  • edit_style_shape 画线

    <?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="rectangle">    <solid android:color="@color/chart_title" />    <size        android:width="10000dp"        android:height="1dp" /></shape>
原创粉丝点击