效果图如下。 纤细的鼠标p align=’center ‘纤细的鼠标pssdjmg类、继承Activity的类、xhdbl、xml文件中纤细的鼠标pgxdlfActivity类:纤细的鼠标pimportaty 纤细的小鼠ppublicclassedittestactivityextendsactivity {纤细的小鼠p/* * calledwhentheactivityisfirstcreated.*/纤细的小鼠p@Override纤细的小鼠ppublicvoidoncreate bundlesavedinstancestate ) )纤细的小鼠psuper.oncreate ) savedinstancestate; 纤细的小鼠psetcontentview r.layout.edit test ); 纤细的小鼠p )纤细的小鼠p )纤细的小鼠p是xhdbl 纤细的小鼠ppackage com.mrzhu.edittest; 纤细的鼠标pimport android.content.Context; 纤细的鼠标pimport android.graphics.Canvas; 纤细的鼠标pimport android.graphics.Color; 纤细的鼠标pimport android.graphics.Paint; 纤细的小鼠pimportandroid.util.attributes et; 纤细的鼠标pimport android.widget.EditText; 纤细的小鼠ppublicclassedittexttestextendsedittext 纤细的小鼠ppublicedittexttest kw dmj ) )纤细的小鼠p super context ); 纤细的鼠标p}纤细的鼠标ppublicedittexttestkwdmj,AttributeSet attrs,int defStyle ) {纤细的鼠标p super } context,attrs,defStyle; 纤细的小鼠p}纤细的小鼠ppublicedittexttestkwdmj,AttributeSet attrs );纤细的小鼠psupercontext,attrs ); 纤细的小鼠p}纤细的小鼠p@Override纤细的小鼠pprotectedvoidondraw canvas canvas )纤细的小鼠pPaint paint=new Paint ); 纤细的小鼠PPAint.settextsize20; 纤细的小鼠PPAint.setcolorcolor.gray; 纤细的鼠标pcanvas.drawText ‘输入提示文本: ‘,10,getHeight )/2 5,paint ); 纤细的小鼠psuper.OndrawCanvas ); 纤细的鼠标p}纤细的鼠标p}纤细的鼠标pedittext.xml文件:纤细的鼠标p纤细的鼠标/p Android : layout _ width=’ match _ parent ‘纤细的小鼠p Android 3360 layout _ height=’ match _ parent ‘纤细的小鼠p Android 3360 ‘纤细的鼠标p Android 3360 layout _ height=’ wrap _ content ‘纤细的鼠标p Android 3360填充文本’纤细的鼠标p Android : id=’ @ id/teted