How to Hide App Title in Android

How to hide app name from title bar in Android?

You have to call `

getSupportActionBar().setDisplayShowTitleEnabled(false) - to hide it,

or

getSupportActionBar().setTitle("new title"); - if you want to change it

How can I hide the app name in androidstudio?

Try to modify your app's AndroidManifest.xml here:

<application
android:label="@string/app_name"
(...)
>

to below:

<application
android:label=""
(...)
>

Thus you don't need to touch the entry in <string name="app_name">app name</string>
in the string resource file.

Remove Android App Title Bar

  1. In the Design Tab, click on the AppTheme Button

  2. Choose the option "AppCompat.Light.NoActionBar"

  3. Click OK.

Row of icons at the top of design view of a layout .xml in Android Studio, The dropdown box with the contrast icon will change the theme.

How to remove title bar from the android activity?

Try this:

this.getSupportActionBar().hide();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

try
{
this.getSupportActionBar().hide();
}
catch (NullPointerException e){}

setContentView(R.layout.activity_main);
}

How to hide the title bar for an Activity in XML with existing custom theme

I now did the following.

I declared a style inheriting everything from my general style and then disabling the titleBar.

<style name="generalnotitle" parent="general">
<item name="android:windowNoTitle">true</item>
</style>

Now I can set this style to every Activity in which I want to hide the title bar overwriting the application wide style and inheriting all the other style informations, therefor no duplication in the style code.

To apply the style to a particular Activity, open AndroidManifest.xml and add the following attribute to the activity tag;

<activity
android:theme="@style/generalnotitle">

How to hide title bar in Main Activity : I'm Using Android Studio

May I know what is your Android Studio version? When you create the activity, you will have this value in your styles.xml

    <style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

Check on your res > values > styles.xml, add it if there is no value like above. Then go to your manifest, add android:theme="@style/AppTheme.NoActionBar" in your activity tag.

<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation"
android:theme="@style/AppTheme.NoActionBar">

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

</intent-filter>

</activity>

For new version of Android Studio, styles.xml has been replaced to themes.xml.

Android Hide or Show Title Bar from the Activity and Fragment

First Change your App theme from res/value/styles.xml to this

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
//leave everything as it is
</style>

After that Add toolbar in your Activity's XML Layout

 <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:background="@color/colorAccent"
app:titleTextColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">

//add your toolbar design here
</toolbar>

Now finally set up your toolbar in Activity Class

public class MyActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_activity_main);

Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);

//need to set toolbar before calling getSupportActionBar
setSupportActionBar(toolbar);

//Now show or hide according to your need
getSupportActionBar().hide();
getSupportActionBar().show();


}
}

Same would be applicable for fragment but for fragment you need to call view first

Toolbar toolbar = getView().findViewById(R.id.toolbar);


Related Topics



Leave a reply



Submit