android - how to scroll up layout when keyboard visible in activity with FULL_SCREEN -
i want scroll layout when softinput keyboard visible.i have define scrollview in xml @ proper place when keyboard visible hides part of layout buttons. have read on stackoveflow link scrollview not works when activity full_screen.if true how can scroll layout when softinput visible.
use custom relative layout detect softkeyboard in ur xml
import android.app.activity; import android.content.context; import android.graphics.rect; import android.util.attributeset; import android.widget.linearlayout; import android.widget.relativelayout; /** * relativelayout can detect when soft keyboard shown , hidden. * */ public class relativelayoutthatdetectssoftkeyboard extends relativelayout { public relativelayoutthatdetectssoftkeyboard(context context, attributeset attrs) { super(context, attrs); } public interface listener { public void onsoftkeyboardshown(boolean isshowing); } private listener listener; public void setlistener(listener listener) { this.listener = listener; } @override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { int height = measurespec.getsize(heightmeasurespec); activity activity = (activity)getcontext(); rect rect = new rect(); activity.getwindow().getdecorview().getwindowvisibledisplayframe(rect); int statusbarheight = rect.top; int screenheight = activity.getwindowmanager().getdefaultdisplay().getheight(); int diff = (screenheight - statusbarheight) - height; if (listener != null) { listener.onsoftkeyboardshown(diff>128); // assume soft keyboards @ least 128 pixels high } super.onmeasure(widthmeasurespec, heightmeasurespec); } } then implements relativelayoutthatdetectssoftkeyboard.listener actiity class
relativelayoutthatdetectssoftkeyboard mainlayout = (relativelayoutthatdetectssoftkeyboard)v.findviewbyid(r.id.dealersearchview); mainlayout.setlistener(this); @override public void onsoftkeyboardshown(boolean isshowing) { if(isshowing) { } else { } } based on keyboard visibility move layout , down using layout params
Comments
Post a Comment