Android TV 全屏无标题

时间:2023-03-09 08:33:28
Android TV 全屏无标题

想要全部窗口全屏无标题,修改

res\values\styles.xml 可设置主题和样式

<resources>

    <!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style> <!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- 设置无标题-->
<item name="android:windowNoTitle">true</item>
<!-- 设置全屏-->
<item name="android:windowFullscreen">true</item>
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style> </resources>

如果要单个窗口设置用如下2个方法

1. 修改AndroidManifest.xml

        <activity android:name=".Convert"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

即加上 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

2. 在代码中设置

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);