Asif Sb
Asif Sb

Reputation: 805

How to set an non editable text on left side of edit text in android?

As we all know that we can set a drawable_left on the EditText using

edittext.setcCompoundDrawablesWithIntrinsicBounds(R.drawable.icon,0,0,0);

Is it possible to set a non editable text say "A" on the left side of the edit text?

Upvotes: 0

Views: 806

Answers (1)

Gabriella Angelova
Gabriella Angelova

Reputation: 2985

You can do this like this (The values are for example):

<RelativeLayout android:layout_width="wrap_content"
                android:layout_height="wrap_content">
    <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="A"
              android:layout_marginRight="10dp"/>
    <EditText android:layout_width="100dp"
              android:layout_height="25dp"
              android:id="@+id/editTextView"
              android:layout_marginLeft="40dp"/>
</RelativeLayout>

Upvotes: 2

Related Questions