Android のソフトキー ボタンを備えたデバイスでレイアウトが大きすぎるという問題があります。
要約すると、私の質問は、「match_parent」として構成されているレイアウトのビュー境界が、ソフトキーボタンのすぐ上ではなく、「実際の」下部ウィンドウの境界に拡張されているのはなぜですか?
今、私の特定の問題に:
ソフトキー ボタンを備えた任意のデバイスでビューlayout_alignParentBottom="true"を使用して RelativeLayout (知る必要がある場合はフラグメント内) を表示すると、ビューはソフトキー ボタンの「後ろ」に表示されます。
ソフトキー ボタンのないデバイスでのビューのイメージ (あるべき姿)
ソフトキー ボタンを備えたデバイスのビューのイメージ (ボタンはソフトキーの後ろに「隠れています」)
RelativeLayout は次のようになります。
<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>
私は Android 開発にまったく慣れておらず、フラグメントで何もしたことがないため、エラーはフラグメント管理にもある可能性があるため、これも投稿します。
フラグメントが表示されるアクティビティは、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>
使用される FrameLayout はすべて、layout_width と layout_height が match_parent に設定されています。
現在、デバイスにソフトキー ボタンが表示されているかどうかをプログラムで確認し、表示されている場合は、このボタンのマージンをより高い値に設定するという回避策を使用しています。
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;
}
}
問題は、Soft-Key-Buttons の高さがデバイスによって異なるため、Soft-Key-Buttons の高さも確認する必要があることです (これは可能であり、StackOverflow で既に回答されています)。
私はこの問題で数週間立ち往生しており、助けていただければ幸いです。