![](/img/trans.png)
[英]How do you create a transparent activity that can overlay the home screen but is not dismissed when the home or back button is pressed?
[英]How To Create Activity Over Home Button
我想在手機上通過主頁按鈕創建一個活動。 在一些設備主頁按鈕覆蓋活動。 我怎么解決這個問題?
謝謝
如果您的意思是導航欄並基於此問題,解決方案是在value-21 style.xml
添加這些屬性:
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:fitsSystemWindows">true</item>
另一種方式是:
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.