3

I have a multilingual app in which I want the EditText to slide up (with the rest of the screen) when the user clicks on it, i.e. the EditText should always be visible above the keyboard, whenever the keyboard is displayed.

enter image description here

Obviously this is doable using android:windowSoftInputMode="adjustResize".

Unfortunately, this seems to work properly only when the app language is English. When the user changes the app language to Arabic, the EditText slides above the keyboard only the first time on all OS versions lower than 7.1.1. It works as expected on Android 7.1.1.

enter image description here

Is this a known issue with Marshmallow 6.0.1 and lower versions? Is there a hack or workaround available to circumvent this?

Yash Sampat
  • 30,051
  • 12
  • 94
  • 120

2 Answers2

1

to fix this issue you need to create customEditText and the override This worked for me.

public class CustomEditText extends android.support.v7.widget.AppCompatEditText {

Context context;

public CustomEditText(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
}

@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
        public static void hideKeyboard(Context context) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, 0);
}

        clearFocus();
    }
    return false;
}

}

then add there two lines to your xml

android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
xbadal
  • 1,284
  • 2
  • 11
  • 24
0

enter image description here

An easy way.you can set edittext gravity to display arabic in RTL like below.either in xml or u can do it dynamically.

In xml do this

 <EditText
    android:padding="15dp"
    android:layout_width="fill_parent"
    android:hint="رمز القسيمة الاختياري"
    android:id="@+id/register"
    android:textColorHint="#d3d3d3"
    android:layout_height="wrap_content"
    android:gravity="right"
    android:background="@android:color/transparent"
    android:textColor="#000000"
    android:textSize="14sp"
   />

Dynamically u can set like this

 textmob.setGravity(Gravity.RIGHT); //textmob is object

Note: you can do the to your textview element

Syed Danish Haider
  • 1,334
  • 11
  • 15