I want to hide the titlebar for some of my activities. The problem is that I applied a style to all my activities, therefore I can\'t simply set the theme to @android:
the correct answer probably is to not extend ActionbarActivity rather extend just Activity
if you still use actionbar activity seems this is working:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide(); //<< this
setContentView(R.layout.activity_main);
}
seems this works too:
styles.xml:
<style name="AppBaseTheme" parent="Theme.AppCompat.Light" >
<item name="android:windowNoTitle">true</item> <!-- //this -->
</style>
i could do like as Scott Biggs wrote. this kind of works. except there is no theme then. i mean the settings menu's background is transparent:
just change
public class MainActivity extends ActionBarActivity {
to Activity or FragmentActivity
public class MainActivity extends Activity {
however i could make it look good enough using material design and not remove the actionbar: https://gist.github.com/shimondoodkin/86e56b3351b704a05e53
it is by example of material design compatibility actionbar styling.
Just use getActionBar().hide();
in your main activity onCreate()
method.
Add
<item name="android:windowNoTitle">true</item>
inside AppTheme (styles.xml)
I'm using a support widget Toolbar v7. So, in order to be able to delete or hide the Title we need to write this.
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
//Remove¡ing title bar
getSupportActionBar().setDisplayShowTitleEnabled(false);
For AppCompat
, following solution worked for me:
Add new theme style with no action bar in your styles.xml
and set parent="Theme.AppCompat.NoActionBar"
.
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimary</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/colorPrimary</item>
</style>
Now implement the same theme style to your splash screen activity in androidManifest.xml
<activity
android:name=".ActivityName"
android:theme="@style/SplashTheme"> // apply splash them here
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Here is result:
First answer is amphibole. here is my explain: add:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
in oncreate() method.
before:
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
(not just before setContentView) if don't do this u will get forceclose. +1 this answer.