I'm having troubles with layouts being too large on Devices with Soft-Key-Buttons on Android:
Summing up, my question is why a layout, which is configured as "match_parent" has its View-bounds extended to the "real" bottom window bound, instead of just above the Soft-Key-Buttons?
Now to my specific problem:
While displaying a RelativeLayout (in a Fragment, if thats necessary to know) with a View layout_alignParentBottom="true" on any Device with Soft-Key-Buttons, the View is displayed "behind" the Soft-Key-Buttons.
Image of the View on a Device without Soft-Key-Buttons (as it should be)
Image of the View on a Device with Soft-Key-Buttons (the Button is "hiding" behind the Soft-Keys)
The RelativeLayout looks like this:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg2">
<LinearLayout
android:layout_marginTop="@dimen/settings_container_margin_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical">
<!-- Some views -->
</LinearLayout>
<at.eventdrivers.android.ui.MenuButton
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
custom:btnText="@string/..." />
</RelativeLayout>
As I'm quite new to Android Development and also have not done anything before with Fragments, the error could also be in the fragment-management, so I'm going to post this too:
The Activity, in which the fragment is shown, is configured in the AndroidManifest:
<activity
android:name=".slidingmenu.SlidingHomeActivity"
android:label="@string/app_name"
android:logo="@mipmap/ic_launcher"
android:theme="@style/AppBaseTheme"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The used FrameLayouts all have layout_width and layout_height set to match_parent.
Right now I'm using kind of a workaround with programmatically checking if the device is showing Soft-Key-Buttons, and if yes, setting the margin of this Button to a higher value:
public static boolean hasSoftKeys(Context c) {
if(Build.VERSION.SDK_INT <= 10 || (Build.VERSION.SDK_INT >= 14 &&
ViewConfiguration.get(c).hasPermanentMenuKey())) {
//menu key is present
return false;
} else {
//No menu key
return true;
}
}
The problem there is, that the Soft-Key-Buttons have a different height on different devices, so I would have to check the height of the Soft-Key-Buttons too (which is possible and already answered on StackOverflow).
I'm stuck at this problem for a few weeks now and would really appreciate any help.