Allow EditText Scrolling During Shutdown

I have EditTextconfigured as follows:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="beforeDescendants"
        android:focusableInTouchMode="true"
        android:orientation="vertical" >

        <EditText
            android:layout_width="match_parent"
            android:layout_height="375dp"
            android:ems="10"
            android:gravity="top">
        </EditText>

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</ScrollView>

At a certain point in the program, after entering text, it is EditTextdisabled using the following code:

edittext.setFocusable(false);
edittext.setEnabled(false);

The problem is that after disconnecting, EditTextI cannot scroll up and down to see what I wrote. How to disable more input, but still allow viewing written?

+4
source share
1 answer

Try installing android:inputType="textMultiLine"on EditText. Even if I already said in the comments: there is an error in the lower API, but with a fixed height, perhaps this will work.

, , TextView EditText, gone, :

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="beforeDescendants"
        android:focusableInTouchMode="true"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/edittext"
            android:layout_width="match_parent"
            android:layout_height="375dp"
            android:ems="10"
            android:gravity="top" >
        </EditText>

        <TextView
            android:id="@+id/textview"
            android:layout_width="match_parent"
            android:layout_height="375dp"
            android:ems="10"
            android:gravity="top"
            android:visibility="gone" >
        </TextView>

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</ScrollView>  

, setOnKeyListener KeyEvent.ACTION_DOWN KeyEvent.ACTION_ENTER, :

edittext.setOnKeyListener(new OnKeyListener() {
    public boolean onKey(View v, int keyCode, KeyEvent event) {
        if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
            String st = edittext.getText().toString();
            textview.setVisibility(View.VISIBLE);
            textview.setText(st);
            return true;
        }
        return false;
    }
});

, .
, .

0

Source: https://habr.com/ru/post/1534566/


All Articles