In my application i am using an activity as a dialog.Everything works fine but there is one small problem.Whenever the dialog is shown,the title bar is visible.I had done requestWindowFeature(Window.No.Title) but still the title bar is comming.
xml
<style name="CustomDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
you are using wrong theme
use this
android:Theme.DeviceDefault.Dialog.NoActionBar
also you can hide action bar programmatic .
for that you have to use this in your onCreate mathod
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.hide();
}
How about this ?
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //before
dialog.setContentView(R.layout.logindialog);
add this before you show the dialog
this answer originally form here
Related
I have a layout A. When i enter to layout A, i want title app or actionbar will be hide.
i have searched in Google.
<style name="AppTheme.Fullscreen">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
But it must do in AndroidManifest.xml
(My app have many screen, and just only layout A, action bar will hide.)
So, i find a way which can set up it into file layout A?
How can i do that ?
use getSupportActionBar().hide(); to hide your action bar programtically
getSupportActionBar().hide();
if you want fullscreen activity than use below code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}
Or you can do it via your AndroidManifest.xml file:
<activity android:name=".YourActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>
I'm creating ProgressDialog compatible with AppCompat. However color accent is not applied in created ProgressBar.
Link to source of my ProgressDialogCompat:
https://github.com/krystian71115/AndroidHelperLibrary/blob/master/src/com/krystian71115/android/app/ProgressDialogCompat.java#L160
The result:
In that screenshot you can see the progress bar in main layout is applied correctly. But when i create this programmatically it doesn't work.
Second screenshot after close dialog:
The colorAccent is working correctly but not working when i create a progress bar programmaticaly.
OnCreate method:
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ProgressDialogCompat dialog = new ProgressDialogCompat(this);
dialog.setTitle("Loading");
dialog.setMessage("Loading data...");
dialog.setProgressStyle(ProgressDialogCompat.STYLE_HORIZONTAL);
dialog.setProgress(150);
dialog.setMax(300);
dialog.show();
}
How can i create ProgressBar horizontal with colorAccent?
Style:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorAccent">#color/red</item>
</style>
I'm using the AppCompat.
I'm testing it on API 22 (emulator).
I'm using a custom background for my ActionBar. I followed the tutorial from here.
My styles.xml looks like this:
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/actionbar_bg</item>
</style>
</resources>
I want this ActionBar to be displayed on each activity, except the login .. so I hid the ActionBar from my login activity (tut from: stackoverflow):
public class Login extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
In my manifest I added the custom theme ... like this:
<application
android:allowBackup="true"
android:label="#string/app_name"
android:theme="#style/MyTheme"
>
When I run the application, I get the error: You need to use a Theme.AppCompat theme (or descendant) with this activity
So I searched on stackoverflow for a solution. I had to extend Activity instead of ActionBarActivity. I did this, also on my Login Activity.
But now ... I can't hide the ActionBar anymore at my Login activity because it doesnt extend ActionBarActivity anymore .. so the following code:
ActionBar actionBar = getSupportActionBar();
Won't work .. anyone have an idea how to still Hide the actionbar at the Login activity, but still with a working custom Actionbartheme?
TL;DR: I want to use a custom actionbar, but I want to hide it on my Login activity. I can let the actionbar work, but only If I let my Login activity extend from Activity, instead of ActionBarActivity - This causes the getSupportActionBar(); to stop working, So I can't hide the actionbar anymore.
Create a theme whose parent is Theme.Holo.Light.NoActionBar. Assign it to your login activity with android:theme parameter.
Just add below code in onCreate Method before setContentView() method :
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // add this line
setContentView(R.layout.login_layout);
In my android project, I wish to disable icon and the title in ActionBar.
Here is the code:
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setDisplayShowHomeEnabled(false);
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
But always on startup they appear and after a while they disappear but i don't want them at all. How can i remove them on startup?
call setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false) on your ActionBar.
actionBar.setDisplayUseLogoEnabled(false); should do it.
Or
For Splashscreen you should use this line in manifest and don't use getActionBar()
<item name="android:windowActionBar">false</item>
and once when Splash Activity is finished in the main Activity use below or nothing
<item name="android:windowActionBar">true</item>
Reffer this ----> click here
You can use below code for that -
<activity android:name="YourActivityname" android:theme="#android:style/Theme.NoTitleBar" />
If you want the full screen of your device you can use below code -
<activity android:name="YourActivityname" android:theme="#android:style/Theme.NoTitleBar.Fullscreen" />
And, also refer Developer's Site
Another method
Do this in your onCreate() method.
//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);
this refers to the Activity.
Maybe this answer can help you. It helped me.
<quote>
Best method is to set the display options to useLogo in your theme. E.g.
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions">useLogo</item>
</style>
This won't actually show the logo (if set) because showHome is not included.
</quote>
try this:
#SuppressLint("NewApi")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
setContentView(R.layout.activity_main);
}
NOTE: The getActionBar() method was added in Honeycomb (API: 11) and later
How to achieve this? It seems very simple, but actually it's not easy to do it in acceptable way. I tried this:
1) in AndroidManifest I set activity theme to Theme.NoTitleBar. However, in my Activity then getActionBar() method returns null => UNUSABLE
2) I hide title programatically in my activity by calling:
actionbar.setDisplayShowTitleEnabled(false);
actionbar.setDisplayShowHomeEnabled(false);
and it helped, but there's a little delay, so I can see title bar maybe quarter of second after activity launch, then it disappears. It looks really lame.
Are there other options?
Apply a custom theme to your Activity, something like:
<style name="TestTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/TestActionBar</item>
</style>
<style name="TestActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/actionbar_background</item>
<item name="android:displayOptions"></item>
</style>
This will show the action bar with the logo, but no title.
Have u try bellow code :-
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getActionBar().hide();
setContentView(R.layout.ur activityxml);
or also try below one
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activityxml);