我需要我的应用程序显示为全屏。现在我知道如何将此功能添加到 Mainfest 中的应用程序标签中
android:theme=”@android:style/Theme.NoTitleBar.Fullscreen"
但是,我有自己的主题,称为“CodeFont”,我不能在同一个应用程序中使用两个主题。如何将此功能添加到资源文件中自己的样式标签中?没有像 android:style 标签这样的东西。
我需要我的应用程序显示为全屏。现在我知道如何将此功能添加到 Mainfest 中的应用程序标签中
android:theme=”@android:style/Theme.NoTitleBar.Fullscreen"
但是,我有自己的主题,称为“CodeFont”,我不能在同一个应用程序中使用两个主题。如何将此功能添加到资源文件中自己的样式标签中?没有像 android:style 标签这样的东西。
使用默认主题创建自定义主题,如下所示
窗口与Fullscreen
<style name="generalnotitle" parent="general">
<item name="android:windowFullscreen">true</item>
</style>
窗口与NoTitle
<style name="generalnotitle" parent="general">
<item name="android:windowNoTitle">true</item>
</style>
使用父属性创建您的自定义主题,以从一般 android 主题继承 NoTitleBar.Fullscreen 属性。
值/样式.xml
<resources>
<style name="CodeFont" parent="android:Theme.NoTitleBar.Fullscreen">
<item name="android:windowNoTitle">true</item>
...
</style>
</resources>
AndroidManifest.xml
<activity
android:name=".MainActivity"
android:theme="@style/CodeFont">
...
</activity>
在 style.xml 添加
<item name="android:windowFullscreen">true</item>
到你的主题。例子:
<style name="CodeFont" parent="android:Theme.Light">
<item name="android:windowFullscreen">true</item>
</style>
您可以使用(例如)请求代码中的一些功能和标志:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.some_layout);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
在应用程序样式中设置主题适用于我的 React Native 应用程序。只需输入android/app/src/main/res/values/styles.xml
:
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar.Fullscreen"></style>
</resources>
在android/app/src/main/AndroidManifest.xml
这个主题的链接中:
<application
...
android:theme="@style/AppTheme">