Android Custom EditText Remove borders and add underscores

Source: Internet
Author: User

<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout    xmlns:android= "http://schemas.android.com/apk/ Res/android "        android:layout_width=" Fill_parent "        android:layout_height=" Fill_parent "        >    <!--notice 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"     />    
//Please add your package name hereImportAndroid.content.Context; ImportAndroid.graphics.Canvas; ImportAndroid.graphics.Color; ImportAndroid.graphics.Paint; ImportAndroid.util.AttributeSet; ImportAndroid.widget.EditText;  Public classLineedittextextendsEditText {PrivatePaint Mpaint; /**      * @paramContext *@paramAttrs*/       PublicLineedittext (Context context, AttributeSet attrs) {Super(context, attrs); //TODO auto-generated Constructor stubMpaint =NewPaint ();          Mpaint.setstyle (Paint.Style.STROKE);      Mpaint.setcolor (Color.Blue); } @Override Public voidOnDraw (canvas canvas) {Super. OnDraw (canvas); //Draw the lineCanvas.drawline (0, This. GetHeight ()-1, This. GetWidth ()-1, This. GetHeight ()-1, Mpaint); }  }  
Importandroid.app.Activity; ImportAndroid.content.Context; ImportAndroid.graphics.Canvas; ImportAndroid.graphics.Color; ImportAndroid.graphics.Paint; ImportAndroid.graphics.Rect; ImportAndroid.os.Bundle; ImportAndroid.text.InputFilter; ImportAndroid.util.AttributeSet; ImportAndroid.widget.EditText;  Public classLineedittexttestextendsActivity {/**Called when the activity is first created.*/      PrivateEditText Medit; @Override Public voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);                    Setcontentview (R.layout.main); Medit=(Lineedittext) Findviewbyid (R.id.myedit); Medit.sethint ("Start typing here ...");          Medit.setsingleline (); Medit.setfilters (Newinputfilter[]{NewInputfilter.lengthfilter (20)}); }        }  

Android Custom EditText Remove borders and add underscores

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.