android--Remove the EditText border, add an underscore,

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"/> </LinearLayout>
//Please add your package name hereImport Android.content.context;import Android.graphics.canvas;import android.graphics.color;import Android.graphics.paint;import Android.util.attributeset;import Android.widget.EditText; Public classLineedittext extends EditText {PrivatePaint Mpaint; /** * @param context * @param attrs*/     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); }}
Import Android.app.activity;import Android.content.context;import android.graphics.canvas;import Android.graphics.color;import Android.graphics.paint;import Android.graphics.rect;import Android.os.Bundle;import Android.text.inputfilter;import Android.util.attributeset;import Android.widget.EditText; Public classLineedittexttest extends Activity {/** 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 ( -)}); }    }

android--Remove the EditText border, add an underscore,

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.