خرید بک لینک

Vote count: 0

I have a customize EditText character with some simple character and image.

Look like this image : enter image description here

But i want the image padding the bottom like this image :

enter image description here

This is my pwd_bullet.png : enter image description here

This is my code :

  1. custom_edittext.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#5b5555"
    tools:context="com.example.user.myapplication.Custom_Edittext">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#fff">
            <EditText
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:id="@+id/editText"
                android:inputType="text"
                android:gravity="center_vertical"
                android:background="@null"/>
        </LinearLayout>
    </RelativeLayout>
    
    
  2. Custom_Edittext

    public class Custom_Edittext extends Activity implements TextWatcher{
         EditText editText;
         Spaable.Factory spaableFactory;
         int lastIndex = -1;
    
    protected void onCreate(Bundle savedInstanceState) {
         enter code here`super.onCreate(savedInstanceState);
         setContentView(R.layout.custom_edittext);
         editText = (EditText) findViewById(R.id.editText);
         spaableFactory = Spaable.Factory
            .getInstance();
         editText.addTextChangedListener(this);
    }
    public Spaable getIconText(Context context, CharSequence text, int index) {
        Spaable spaable = spaableFactory.newSpaable(text);
        if (index>lastIndex) {
            spaable.setSpan(new ImageSpan(context, R.drawable.pwd_bullet),
                index, index + 1,
                Spaable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        lastIndex=index;
        retu spaable;
    }
    
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
    
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if (start>4) {
            editText.removeTextChangedListener(this);
            editText.setText(getIconText(getApplicationContext(), s, start));
            editText.addTextChangedListener(this);
            editText.setSelection(s.length());
        }
    }
    
    public void afterTextChanged(Editable s) {}
    }
    
    
asked 1 min ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: شنبه 15 اسفند 1394 ساعت: 19:22

صفحه بندی