简体   繁体   English

如何在主页按钮上创建活动

[英]How To Create Activity Over Home Button

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 谢谢

If you mean navigation bar and based on this question, the solution would be adding these properties in value-21 style.xml : 如果您的意思是导航栏并基于问题,解决方案是在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;

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM