android--Remove EditText border, add underline

Source: Internet
Author: User

<span style= "font-family:arial, Helvetica, Sans-serif;" ><?xml version= "1.0" encoding= "Utf-8"?>    </span>
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"        android:layout_width= "Fill_ Parent "        android:layout_height=" fill_parent "        >    <!--Note Name---    < Com.marine.study.LineEditText                 android:id= "@+id/myedit"        android:layout_width= "Fill_parent"         android: layout_height= "Wrap_content"         style= "?

Android:attr/textviewstyle " android:background=" @null " android:textcolor=" @null " /> < /linearlayout>


Background, can be set into other colors, etc.

TextColor not necessarily null, can set font color


Add underline

public class Lineedittext extends EditText {      //brushes are used to draw the underlined    private paint paint;        Public Lineedittext (context context, AttributeSet Attrs) {          Super (context, attrs);          Paint = new paint ();          Paint.setstyle (Paint.Style.STROKE);          Paint.setcolor (color.red);         Turn on anti-aliasing memory         Paint.setantialias (TRUE);     }    @Override     protected void OnDraw (canvas canvas) {         super.ondraw (canvas);         Gets the total number of rows         int linecount = Getlinecount ();         Get the height of each line         int lineheight = Getlineheight ();         Draw lines based on the number of rows for         (int i = 0; i < LineCount; i++) {             int liney = (i + 1) * lineheight;             Canvas.drawline (0, Liney, This.getwidth (), Liney, Paint);}}}  


android--Remove EditText border, add underline

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.