【问题标题】:Remove Title bar in my android application删除我的 android 应用程序中的标题栏
【发布时间】:2015-01-16 12:04:55
【问题描述】:

我想从我的应用程序中删除标题栏,但是当我使用 Theme.Light.NoTitleBar 时,它会在样式 xml 文件中显示错误 这是我的样式 xml 文件

<!--
    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="Theme.AppCompat.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">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>

这是我的清单文件

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" > 

【问题讨论】:

标签: android


【解决方案1】:
//add to AndroidManifest for SplashScreen
<activity
         android:name="<YOUR_PACKAGENAME.ACTIVITY>"
         android:theme="@style/AppTheme.NoActionBar"
         .........../>
//add this styles to  styles.xml

 <style name="AppTheme.NoActionBar">
    <item name="android:background">@android:color/transparent</item>
    <item name="android:windowDisablePreview">true</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@null</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

//add this code to Activity
public class SplashScreen extends AppCompatActivity {
.
.
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    .
    .
    .
    }

}

【讨论】:

    【解决方案2】:

    以编程方式

    this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.activity_home);
    

    来自清单文件

    <activity
            android:name="<YOUR_PACKAGENAME.ACTIVITY>"
            android:theme="@android:style/Theme.Black.NoTitleBar" >
    

    你就完成了:)

    【讨论】:

      【解决方案3】:

      试试这个

      this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Remove title bar
      setContentView(R.layout.activity_home);
      

      注意:移除 Title Bar 、Notification Bar 等功能必须在 setContentView(layout_id); 之前调用

      【讨论】:

        【解决方案4】:

        它使用所有 Activity 的第一种方式

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        

        在标签栏正下方的工具栏上,有一排图标。单击看起来像星星的那个,然后转到全部 -> Theme.NoTitleBar(.Fullscreen)

        Source

        【讨论】:

          【解决方案5】:

          试试这个:

           <style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
                <item name="android:windowNoTitle">true</item>
           </style>
          

          【讨论】:

          • 它给出了这样的错误:检索项目的父项时出错:找不到与给定名称“Theme.AppCompat.Light.NoActionBar”匹配的资源
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2016-10-25
          • 1970-01-01
          • 2015-05-28
          • 1970-01-01
          • 2011-10-24
          • 2011-10-24
          • 1970-01-01
          相关资源
          最近更新 更多