i have edit text inside bottom sheet fragment. when focus come on edit text layout goes . tried
android:windowsoftinputmode="adjustnothing"
its work parent activity not dialog fragment
this bottom sheet class
public class custombottomsheetdialogfragment extends bottomsheetdialogfragment { @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater.inflate(r.layout.content_dialog_bottom_sheet, container, false); getdialog().getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_adjust_resize); return v; }
}
initial state
when keyboard comes
i want layout stay on bottom keyboard should come above layout.
check layout
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/bottomsheetlayout" android:layout_width="match_parent" android:layout_height="400dp" android:background="@android:color/holo_blue_light" android:padding="@dimen/activity_vertical_margin" app:behavior_hideable="true" app:behavior_peekheight="60dp" app:layout_behavior="@string/bottom_sheet_behavior"> <edittext android:id="@+id/edt" android:layout_width="match_parent" android:layout_height="40dp" android:background="@android:color/white" android:padding="10dp" /> <textview android:layout_width="wrap_content" android:layout_height="250dp" android:layout_below="@+id/edt" />
use in
dialog fragment
.
getdialog().getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_adjust_resize);
inside
oncreateview
this.
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.dialog_fragment, container); //set adjust screen height automatically, when soft keyboard appears on screen getdialog().getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_adjust_resize); return rootview; }
edit 1:
i have made changes
layout
using make apply in currentlayout
.
here layout
.
<?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/bottom_sheet" android:layout_width="match_parent" android:layout_height="400dp" android:layout_gravity="bottom" android:background="@android:color/holo_blue_light" android:padding="10dp" app:behavior_hideable="true" app:behavior_peekheight="60dp" app:layout_behavior="android.support.design.widget.bottomsheetbehavior"> <scrollview android:layout_width="match_parent" android:layout_height="match_parent" android:fillviewport="true" android:isscrollcontainer="false" android:scrollbars="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <edittext android:id="@+id/edt" android:layout_width="match_parent" android:layout_height="40dp" android:background="@android:color/white" android:padding="10dp" /> <textview android:layout_width="wrap_content" android:layout_height="250dp" android:layout_below="@+id/edt" /> </linearlayout> </scrollview> </framelayout>
here fragment
.
public class testfragment extends bottomsheetdialogfragment { @nullable @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view v = inflater.inflate(r.layout.test4, container, false); return v; }
edit 2:
you can try android:elevation="50dp" property shadow above bottom sheet give try in frame layout.
Comments
Post a Comment