1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      EditText之自定義邊框顏色

      EditText之自定義邊框顏色

      成都創(chuàng)新互聯(lián)公司成都網(wǎng)站建設(shè)按需定制制作,是成都網(wǎng)站營銷公司,為成都活動板房提供網(wǎng)站建設(shè)服務(wù),有成熟的網(wǎng)站定制合作流程,提供網(wǎng)站定制設(shè)計(jì)服務(wù):原型圖制作、網(wǎng)站創(chuàng)意設(shè)計(jì)、前端HTML5制作、后臺程序開發(fā)等。成都網(wǎng)站建設(shè)熱線:18982081108

      有倆種方式可以達(dá)到效果

      一種是網(wǎng)上比較推崇的用圖作背景,另一種則是自繪

      圖作背景的:

        首先重新定義一個(gè)style。在values文件夾下新建一個(gè)style.xml文件:

            

              

                 

              


       接下來在drawable里添加my_edittext.xml:內(nèi)容如下

           

           其中editbox_normal為正常情況下的編輯框圖片,editbox_focus為選中下的編輯框圖片

       定義好了這兩個(gè)文件之后就可以用以下方式使用:

         

           

            android:text="My EditText"

            android:layout_width="fill_parent"

            android:layout_height="wrap_content">

         

         以上用圖做背景的部分是引用http://blog.csdn.net/sinat_31998357/article/details/49491603里的

           PS:圖最好用九宮圖 這樣會自適應(yīng)的


      自繪的方式:

         先自定義一個(gè)EditText:


            package com.MyView;

            import android.content.Context;

            import android.graphics.Canvas;

            import android.graphics.Color;

            import android.graphics.Paint;

            import android.graphics.RectF;

            import android.graphics.Paint.Style;

            import android.util.AttributeSet;

            import android.widget.EditText;

            public class MyEditText extends EditText{

               public MyEditText(Context context, AttributeSet attrs) {

                  super(context, attrs);

               }

             @Override

             protected void onDraw(Canvas canvas) {


                Paint paint = new Paint();

                paint.setStyle(Style.STROKE);

                paint.setStrokeWidth(2);

                if(this.isFocused() == true)

                    paint.setColor(Color.parseColor("#122e29"));

              else

                   paint.setColor(Color.rgb(0,173,173));

              canvas.drawRoundRect(new RectF(2+this.getScrollX(), 2+this.getScrollY(), this.getWidth()-3+this.getScrollX(), this.getHeight()+ this.getScrollY()-1), 3,3, paint);

              super.onDraw(canvas);

           }

         }

      xml里引用:


         

             android:id="@+id/view"

             android:focusable ="true"   

             android:gravity="center"

             android:layout_x = "12dip"

             android:layout_y = "402dip"

             android:layout_width="104dip"

             android:layout_height="46dip"

             android:background = "#fffef9"

          />

         

             android:id="@+id/tv_state"

             android:focusable ="true"   

             android:gravity="center"

             android:layout_x = "10dip"

             android:layout_y = "400dip"

             android:layout_width="110dip"

             android:layout_height="50dip"

             android:background = "#00000000"http://背景透明色

          />

      弄一個(gè)View在EditText下面的目的是設(shè)置輸入框內(nèi)部顏色,如果直接設(shè)置EditText背景色的話,圓角矩形那不太好處理,如果在onDraw里畫背景色的話,這樣光標(biāo)就會不顯示,被遮住了


      分享題目:EditText之自定義邊框顏色
      文章地址:http://www.ef60e0e.cn/article/jospie.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        东方市| 利川市| 中江县| 右玉县| 肃宁县| 比如县| 友谊县| 承德市| 卫辉市| 黑龙江省| 泸水县| 双牌县| 武鸣县| 桃园县| 郴州市| 邯郸市| 芜湖县| 永顺县| 建水县| 栾城县| 钟祥市| 德昌县| 错那县| 大冶市| 饶平县| 东辽县| 宁晋县| 宿松县| 崇信县| 青阳县| 德安县| 师宗县| 会宁县| 伊川县| 嘉黎县| 都兰县| 盐亭县| 石楼县| 布尔津县| 镇坪县| 临沂市|