0

Am learning android and working on project as well.I just created an android project in android studio and tried to hide the title bar. more over i have tried all solutions has been using now.but its not working.

I have tried the following sites what they would have done solution for this issue.

http://stackoverflow.com/questions/28080250/android-feature-no-title-not-working
http://stackoverflow.com/questions/9737112/requestwindowfeaturewindow-feature-no-title-causing-the-app-to-crash
http://stackoverflow.com/questions/21354365/android-requestwindowfeaturewindow-feature-no-title-exception
http://stackoverflow.com/questions/27891030/requestwindowfeaturewindow-feature-no-title-error
http://stackoverflow.com/questions/25164171/requestwindowfeaturewindow-feature-no-title-not-working-in-froyo-and-gingerbr
http://stackoverflow.com/questions/25119013/can-not-remove-title-bar-in-activity#

And here is my android manifest file

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

MainActivity.java

 public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

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>
</style>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.raju.androidpractice.MainActivity">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />
</RelativeLayout>

I know this very very basic question but whenever i search regarding this issue there is no proper answer and explanation

Would appreciate expected solution with brief about this issue.Thanks in advance

Raju
  • 1,183
  • 3
  • 11
  • 19

5 Answers5

2

Replace your code
Change extends ActionBarActivity to AppCompatActivity

<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>

To

<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>

Change theme name android:theme="@style/AppTheme"

and remove requestWindowFeature(Window.FEATURE_NO_TITLE); code in your activity file

Vinothkumar Nataraj
  • 588
  • 2
  • 7
  • 23
1

Add the following in the <style> tag in res/values/styles.xml:

<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
Dang Nguyen
  • 354
  • 2
  • 9
0

So you just want to remove the title of the action bar? It's very simple: just set this android:label="@string/app_name" to whatever you want the title or android:label="" if you want no title.

Andrei Pascale
  • 232
  • 1
  • 3
  • 16
0

If your goal is just to hide the title bar (ToolBar), there is a method for that already.

Try

getSupportActionBar().hide();

Inside the onCreate method of your activity

  • Test this out just now and it is working fine. Placing the getSupportActionBar().hide(); after setContentView(). Could you uninstall the old app from the device and apply the code before you re-run the app and let's see – Hassan Semiu Ayomon Jul 27 '16 at 10:20
0

try enabling your Activity to Full mode

activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide();
rahul sharma
  • 149
  • 1
  • 2
  • 11