У меня есть код, чтобы проверить, видна ли клавиатура Softinput или нет.Но я не знаю, как установить кнопку, которая изначально находится в нижней части макета, чуть выше клавиатуры. Я установил макет на FULL SCREEN , поэтому softInputMode присвоено значение AdjustResize в Манифесте больше не будет работать. Я знаю это. Пока я просто устанавливаю позицию «Y» кнопки ( id = next ) на некоторое значение вышеКлавиатура. Но я хочу, чтобы она была чуть выше клавиатуры. Жду вашей помощи !! Заранее спасибо.
Java-код:
final Window mRootWindow=getActivity().getWindow();
frag1Binding.relative.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int screenheight=frag1Binding.relative.getRootView().getHeight();
Rect r=new Rect();
View view=mRootWindow.getDecorView();
view.getWindowVisibleDisplayFrame(r);
int keyboardheight=screenheight-r.bottom;
if (keyboardheight>150){
lastheight=keyboardheight;
Log.e("EditText_Bottom",Integer.toString(frag1Binding.phnmbr.getBottom()));
linearLayoutParams=new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
orginalpositon=frag1Binding.next.getY();
Log.e("Original Y",Float.toString(frag1Binding.next.getY()));
frag1Binding.next.setY(100);
}
else {
if (lastheight>150){
frag1Binding.next.setY(orginalpositon);
}}
}
});
XML:
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:id="@+id/relative"
>
<TextView
android:id="@+id/head"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/ph_verify_lbl_mrgn"
android:text="verify_your_phone_number"
android:textColor="#bb2b67"
android:textSize="@dimen/ph_verify_head_tsxtsze"
/>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/head"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:text="lorem_ipsum_lorem_ipsum"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:text="+91"
android:layout_below="@+id/textView"
android:gravity="center|bottom"
android:id="@+id/countrycode"
android:textSize="@dimen/ph_verify_head_tsxtsze"
android:textColor="#000000"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
/>
<EditText
android:layout_width="312dp"
android:layout_height="60dp"
android:id="@+id/phnmbr"
android:layout_toRightOf="@+id/countrycode"
android:layout_below="@+id/textView"
android:background="@drawable/edittext_bg"
android:hint="Hint"
android:inputType="number"
android:gravity="start|center|bottom"
android:paddingLeft="20dp"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:focusable="true"
android:fitsSystemWindows="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/phnmbr"
android:layout_alignParentBottom="true"
>
<Button
android:id="@+id/next"
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_alignParentBottom="true"
android:background="@drawable/button_bg"
android:text="NEXT"
android:textColor="#ffffff"
android:textSize="22sp">
</Button>
<ImageView
android:id="@+id/imageView"
android:layout_width="20dp"
android:layout_height="25dp"
android:elevation="2dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="18dp"
android:layout_marginEnd="19dp"
android:background="@drawable/arrow"
android:layout_alignParentRight="true"
android:layout_marginRight="19dp"/>
</RelativeLayout>
</RelativeLayout>
</layout>