Java 实用地检测MIUI/Xiomi设备中的软导航栏可用性?
此问题针对的是带有MIUI的Xiomi设备的问题。 如何检测选择了全屏模式(手势)或导航按钮(软导航) 我尝试过一些解决方案,但在其他设备上也可以,但在Xiomi或MIUI上不起作用 我已经在SO上尝试了此解决方案,因此如果您有,请提供另一个解决方案 1. 2. 3. 你知道如何知道导航栏当前是否可见吗 我还试图计算实际宽度和可用宽度,似乎MIUI总是返回导航栏的保留宽度Java 实用地检测MIUI/Xiomi设备中的软导航栏可用性?,java,android,xiaomi,miui,Java,Android,Xiaomi,Miui,此问题针对的是带有MIUI的Xiomi设备的问题。 如何检测选择了全屏模式(手势)或导航按钮(软导航) 我尝试过一些解决方案,但在其他设备上也可以,但在Xiomi或MIUI上不起作用 我已经在SO上尝试了此解决方案,因此如果您有,请提供另一个解决方案 1. 2. 3. 你知道如何知道导航栏当前是否可见吗 我还试图计算实际宽度和可用宽度,似乎MIUI总是返回导航栏的保留宽度 谢谢。对于全屏活动,无需检测软输入导航栏是否可见或隐藏。您可以创建样式并将样式应用于活动 <style name="
谢谢。对于全屏活动,无需检测软输入导航栏是否可见或隐藏。您可以创建样式并将样式应用于活动
<style name="Theme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="lollipop">false</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
这会导致您停止软输入导航的布局重叠。我也有同样的问题。我找到了两个解决方案:
public static int isEdgeToEdgeEnabled(Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("config_navBarInteractionMode", "integer", "android");
if (resourceId > 0) {
return resources.getInteger(resourceId);
}
return 0;
}
ViewCompat.setOnApplyWindowInsetsListener(
findViewById(android.R.id.content)
) { _: View?, insets: WindowInsetsCompat ->
navigationBarHeight = insets.systemWindowInsetBottom
insets
}
我自己也使用了2种方法对不起,但这并不能回答问题。您是否找到了检查方法?我也试着这么做thing@moyo甚至我也有同样的问题
<style name="Theme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="lollipop">false</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
public static int isEdgeToEdgeEnabled(Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("config_navBarInteractionMode", "integer", "android");
if (resourceId > 0) {
return resources.getInteger(resourceId);
}
return 0;
}
ViewCompat.setOnApplyWindowInsetsListener(
findViewById(android.R.id.content)
) { _: View?, insets: WindowInsetsCompat ->
navigationBarHeight = insets.systemWindowInsetBottom
insets
}