2017-09-04 152 views
-4

嗨,我是Android開發的初學者。 我嘗試刪除這樣android:theme="@android:style/Theme.NoTitleBar"刪除標題欄(Android)

絲毫不差吧,但它不工作

+0

請參閱此鏈接https://stackoverflow.com/a/2591311/3364266 –

回答

0

試試這個清單文件:

<activity android:name=".MainActivity" 
      android:label="@string/app_name" 
      android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> 
0

的Android manifest.xl當u加入活動 添加此代碼

<activity 
     android:name=".activity.MainActivity" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme.NoActionBar"> 
0

1 。適用這個主題來移除整個標題欄在你style.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

比應用TI這樣

<activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme.NoActionBar"> 

2.您的活動試試這個全屏活動

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     // remove title 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
      WindowManager.LayoutParams.FLAG_FULLSCREEN); 
     setContentView(R.layout.activitymain); 
    } 

3.也試試這個

<activity android:name=".YourActivity" 
      android:label="@string/app_name" 
      android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> 
0

,你也可以的setContentView之前在您的活動試試這個:

//Remove title bar 
this.requestWindowFeature(Window.FEATURE_NO_TITLE); 

//Remove notification bar 
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 

//set content view AFTER ABOVE sequence (to avoid crash) 
this.setContentView(R.layout.your_layout_name_here); 
0

你應該定義在styles.xml文件應用程序的風格,而不是單獨的佈局文件。以下是我的一個項目的示例:

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
     <item name="android:windowActionBarOverlay">true</item> 
     <item name="colorControlActivated">@color/colorSecondaryDark</item> 
    </style> 

</resources>