Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

edittext disabled and scroll horizontal

I want to do scroll when the EditText is disabled and contains a large text in 1 line.

I try edittext.setInputType(InputType.TYPE_NULL)

but background don't change, and users can not tell the difference when they can edit or not.

EDIT: my xml:

<EditText
                android:id="@+id/et_address"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:inputType="text"
                android:maxLength="120"
                android:maxLines="1"
                android:singleLine="true"
                android:nextFocusDown="@+id/et_name" />

the horizontal scroll works fine when edittext is enable, i want the same when edittext turn disabled

like image 815
thenosic Avatar asked Oct 26 '25 04:10

thenosic


1 Answers

Better use textview and set background like edittext using XML style

            <TextView
                android:id="@+id/output"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_marginLeft="2dp"
                android:layout_marginTop="2dp"
                android:layout_weight="1"
                android:background="@drawable/btnstyle"
                android:hint="@string/convert"
                android:inputType="number"
                android:textColor="#000000"
                android:scrollbars="horizontal"
                android:scrollHorizontally="true"
                android:gravity="left|center"
                android:textSize="18sp"

               />

and set

        Output = (TextView) findViewById(R.id.output);
        Output.setMovementMethod(new ScrollingMovementMethod());

Hope this Helpful

like image 181
APriya Avatar answered Oct 27 '25 17:10

APriya