Как удалить строку заголовка в Android API 22 и API 25?

Я использую андроид-студию 2.2.3. Как я могу удалить строку заголовка из моего приложения? Я пытаюсь поставить

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

в файле AndroidManifest.xml, но это не сработало.

Вот скриншот моего проекта Мой проект

Код моего файла Style.xml:

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

Что должно измениться в файле style.xml?


person Harsh Trivedi    schedule 21.01.2017    source источник
comment
stackoverflow.com/ вопросы/10086371/   -  person IntelliJ Amiya    schedule 21.01.2017


Ответы (3)


Добавьте этот стиль в Style.xml

<!-- Base application theme. -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->

    </style>
    <style name="AppTheme" parent="AppBaseTheme">
        - <!--  All customizations that are NOT specific to a particular API-level can go here.
  -->
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
person Akp    schedule 21.01.2017
comment
Спасибо, брат, это работает. Есть ли какой-нибудь другой метод, который вы знаете, кроме этого? - person Harsh Trivedi; 21.01.2017

Программный способ

  @Override
    protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       this.requestWindowFeature(Window.FEATURE_NO_TITLE);
       this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
       setContentView(R.layout.your_xml);
person IntelliJ Amiya    schedule 21.01.2017

Просто измените свою строку таким образом

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

to

android:theme="@style/Theme.AppCompat.NoActionBar"
person TysonSubba    schedule 21.01.2017
comment
Это также не будет работать...!! <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" android:theme="@style/Theme.AppCompat.NoActionBar" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> - person Harsh Trivedi; 21.01.2017