0

I want to create an activity over home button on phone. In some devices home button overlay activity. How can I solve this problem?

Thanks

drojokef
  • 425
  • 1
  • 5
  • 15

1 Answers1

0

If you mean navigation bar and based on this question, the solution would be adding these properties in value-21 style.xml :

<item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:fitsSystemWindows">true</item>

another way would be:

public static int getSoftButtonsBarSizePort(Activity activity) {
// getRealMetrics is only available with API 17 and +
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    DisplayMetrics metrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int usableHeight = metrics.heightPixels;
    activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
    int realHeight = metrics.heightPixels;
    if (realHeight > usableHeight)
        return realHeight - usableHeight;
    else
        return 0;
}
return 0;

}

Payam Asefi
  • 2,677
  • 2
  • 15
  • 26