Reputation: 21
I am using using slide up panel provided by https://github.com/umano/AndroidSlidingUpPanel
I have set the windowSoftInputMode
as resize
in activity manifest file as follows (I have only one activity)
android:windowSoftInputMode="adjustResize"
The structure for layout for slideupPanel:
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoDragView="@+id/customDragViewId">
<FrameLayout android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/customDragViewId"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<include
android:layout_width="match_parent"
android:layout_height="55dp"
layout="@layout/another_layout" />
<include
android:layout_width="wrap_content"
android:layout_height="0dp"
layout="@layout/yet_another_layout"
android:layout_weight="1" />
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
When i have inflate an EditText
into the container(@+id/container
) and get it into focus, the soft keypad is shown. On this, the @+id/sliding_layout
is re-sized to fit the screen. But the container
height remains same as the sliding_layout
when it should be re-sized to end at top of customDragViewId
. The container only re-sizes when the bottom sliding panel(@+id/customDragViewId
) is dragged.
What should i do so that the container is always re-sized accordingly ?
Also when i set the panel State to hidden (see the following code), the sliding_layout height is not re-sized at all when the keypad shows up. What should i do that sliding_layout is re-sized?
SlidingUpPanelLayout sliding_layout = (SlidingUpPanelLayout) getActivity().findViewById(R.id.sliding_layout);
sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
Note: All the layout elements in bold letters(ex: container) correspond to their ids.
Upvotes: 2
Views: 342
Reputation: 41
I would love to know if you ever figured this out.
I am having the same issue, I found it leads down to the function that makes the tab bar GONE when the keyboard is opened. If I comment that line it works fine.
Here is that function:
getActivity().getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
getActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
int screenHeight = getActivity().getWindow().getDecorView().getRootView().getHeight();
int keypadHeight = screenHeight - r.bottom;
if (keypadHeight > screenHeight * 0.15) {
//Keyboard is opened
nav_view.setVisibility(View.GONE); // If I comment this line the resize works
}
else {
// keyboard is closed
new Handler().postDelayed(new Runnable() { @Override public void run() {
nav_view.setVisibility(View.VISIBLE);
}}, 20);
}
}
});
Upvotes: 0