Hiding Dialog's titlebar in Android Manifest - android

Basically, I created an Activity inside a dialog, everthing is seems working perfectly but the problem is the title bar of a dialog is still there. Is there anyway to hide it?
And also this is the tutorial, here is the link. It is exactly what I am trying to accomplish except witout title bar.
Note: THIS IS NOT JUST AN ALERTDIALOG OR DIALOG, THIS IS AN ACTIVITY INSIDE A DIALOG which only became looks like a dialog by pasting the code below.
<activity android:label="My Dialog (activity)" android:name=".MyActivity" android:theme="#android:style/Theme.Dialog"></activity>

If ur using appcompat support v4, v7 libraries then try using
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
before setContentView and also before super.Oncreate();

You can remove the title bar programatically.
Add this line to your Activity onCreate() method.
requestWindowFeature(Window.FEATURE_NO_TITLE);
Edit:
Create a custom style that extend Theme.Dialog:
<resources>
<style name="NoTitleDialog" parent="android:Theme.Dialog">
<item name="android:windowNoTitle">true</item>
</style>`
</resources>
Then reference this theme in your activity android:theme attribute. :)

I came up with such, easiest solution:
In Manifest
android:theme="#android:style/Theme.Holo.Light.Dialog.NoActionBar">
Seems to work.

Try this :
style.xml
<style name="NoTitleActivityDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="windowNoTitle">true</item>
</style>
AndroidManifest.xml
<activity
android:name=".DialogActivity"
android:theme="#style/NoTitleActivityDialog"/>

Related

How to show an Activity as a dialog box rather than a new screen?

I am pretty new to this. I made 2 Activities. From Activity A I want to be able to open Activity B as a dialog window instead of it taking over the screen. I figured out how to make a dialog, but it seems its functionality needs to be programmed into the same Activity Java file. I want to keep my code separate.
Is there a way to show a dialog window that contains another activity along with all of it's coded functionality?
In your AndroidManifest manifest file define your activity like this :
<activity android:theme="#android:style/Theme.Dialog"
android:excludeFromRecents="true" />
and If you want your activity to not be cancelable when the user clicks outside it just add the following line in your Activity.Java file inside onCreate method :
this.setFinishOnTouchOutside(false);
Try the following for the activity :
In the activity,set the Theme by calling
setTheme(R.style.AppTheme_DialogTheme)
and create a corresponding style :
<style name="AppTheme.DialogTheme"
parent="Base.Theme.AppCompat.Light.Dialog.FixedSize">
<!-- removing the dialog's action bar -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="windowFixedHeightMajor">400dp</item>
<item name="windowFixedHeightMinor">400dp</item>
</style>
Set you activity B theme from manifest.
<activity android:theme="#android:style/Theme.Dialog" />
Yes, you have to make some changes in the Manifest.
you can refer to this because your question has already been asked:
android activity as a dialog

Not able to set transparent background for Popup Window Activity

I am following this particular example to create a popup window activity but when I click on a button to open this activity, the background is not semi-transparent as mentioned in the example. I am new to android kotlin development so I am not able to figure this out on my own. Let me know what I am doing wrong.
EDIT: This link tells a different method but working fine.
You can customize the translucent theme of your activity, in your "AndroidManifest.xml" file.
<activity
android:name=".ui.PopUpWindow"
android:theme="#style/AppTheme_translucent" />
and in your "styles.xml" file.
<style name="AppTheme_translucent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowBackground">#color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
</style>
I travel the code and did not see setContentView() method for PopupWindow activity. Please set content view for the activity by calling the method inside PopupWindow's onCreate()

How to create Android application without ActionBar using new theme in API9?

I need to create application wihtout actionbar. I will try to explain how I create application(maybe I am missing some steps).
1.I am intentionally not choosing "Holo Light with Dark Action Bar" option. I thought this make application without action bar.
2.Leaving next page as default:
3.Leaving next page as default:
4.On the next page, it becomes interesting. Blank Activity's description says that it creates a new blank activity an action bar. On Empty Activity's description: Creates a new empty activity. So I choose Empty activity
5.Leaving next page as default.
Result:As usually, application was created with ActionBar.
Tried this solution:getActionBar().hide();. In this solution, ActionBar is hiden after some milliseconds.
Tried to use android:theme="#android:style/Theme.NoTitleBar" in AndroidManifest.xml->application tag. But in this solution, application uses old theme.
My question: how to create Android application without ActionBar using new theme and leaving StatusBar enabled?
PS. I remember, about one year ago, in Eclipse, applications were created without ActionBar. Then we added it manually
Put this right after super.onCreate(savedInstanceState); in the onCreate method of your activity(s):
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Make sure you put this BEFORE this.setContentView(R.layout.activity_example); to avoid crashes
When your project is started you can use public activity extends Activity instead of using ActionBarActivity this will also remove the action bar or there is another way
<android:theme="#android:style/Theme.NoTitleBar">
or you can see these links they might help
How to hide action bar before activity is created, and then show it again?
Remove android default action bar
Refer this code and change as per your requirement:
Update :
styles.xml :
<style name="FullscreenTheme" parent="android:Theme.Holo">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:actionBarStyle">#style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar">
<item name="android:background">#color/black_overlay</item>
</style>
These will remove actionbar and keeps your theme as it is .
Note : Here i have tested using Theme.Holo . you can use yours.
AndroidManifest.xml
<activity
android:name=".GridViewExample"
android:theme="#style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
It gives you activity without ActionBar.
Hope this solves your problem.
You can do it programatically:
public class ActivityName extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
Or you can do it via your AndroidManifest.xml file:
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>
EDIT :
If your app uses any other theme use corresponding theme name E.g. For White theme #android:style/Theme.Holo.Light.NoActionBar.Fullscreen

Android - Disable dummy starting window of application

I want to know how to achieve this effect.
My app (default everything), when launcher icon is clicked, right away display some kind of a empty dummy window, where nothing is happening and then loads layout into it.
"Heavier" apps like YouTube, Drive, Dropbox etc. when started, seem to wait after launch, without showing that dummy window and load right into ready layout.
Any idea how to do this or where should I look into?
Thanks
//EDIT: this has nothing to do with something like loading database, where I should display progressBar, imho this has to do with stuff before activity exists.
I suggest you don't disable the dummy loading window using:
<style name="Theme.MyTheme" parent="android:style/Theme" >
....
<item name="android:windowDisablePreview">true</item>
....
</style>
because you could run into several problems. For example, if you try to animate an AlertDialog, enter animation will not work (personal experience).
The right solution is to set the theme of your application like to your main activity screen (same ActionBar style, same background color).
In my application after severals experiments i found the right solution for my needs.
(I have a main activity with blank background, no ActionBar, just full screen personal layout)
1 - styles.xml: add new style like this (remove ActionBar and set the same background color of my main activity)
<style name="LoadingTheme" parent="#android:style/Theme.Light.NoTitleBar.Fullscreen">
<item name="android:windowBackground">#color/white_smoke</item>
</style>
2 - AndroidManifest.xml: set my theme for main activity to "LoadingTheme"
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.company.appname.MainActivity"
android:label="#string/app_name"
android:theme="#style/LoadingTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
....
</application>
And finally i have full blank dummy loading window without ActionBar with soft MainActivity load and working animations.
Hope to be helpful.
<style name="Theme.MyTheme" parent="android:style/Theme" >
....
<item name="android:windowDisablePreview">true</item>
....
</style>
but use with caution
This will create a custom preview window for your activity.
Create a style in styles.xml like
<style name="MyTheme" parent="#android:style/Theme.Holo.NoActionBar">
<item name="android:windowBackground">#color/myBackgroundColor</item>
</style>
In your Manifest file use the theme created above.
For eg:
<activity android:name=".MyActivity"
android:label="#string/app_name"
android:theme="#style/MyTheme"
/>
In your activity change the background of the window back to null in onCreate()
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setBackgroundDrawable(null);
setContentView(R.layout.main);
}
You can call the setContentView method anywhere you'd like in your activity. Before calling this method it will display a blank screen. If you wanted a splash screen, you can call the setContentView method within the onCreate method to display the splash screen view. Then when you're ready to display the "main" view you can use a LayoutInflater to display it. I also suggest using a ProgressDialog to show the user that information is loading.
Load your resources before setting the contentview. There will be a dummy window until you would not set view using setContentView.
EDIT
To avoid this screen. Make there changes to your code.
1) Do not do any heavy work in activity onCreate method. Run a separate thread for it.
2) Set content view right after the super.onCreate() line
super.onCreate(savedInstanceState);
setContentView (R.layout.splash_screen);
3) Apply following theme to your application.
Define theme in style
<resources>
<style name="Theme.MyTheme" parent="android:style/Theme" >
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#drawable/any_default_background</item>
</style>
</resources>
In your Manifest
<application
....
android:theme="#style/Theme.MyTheme"
....
>
Thats It.

Remove icon/logo from action bar on android

I've been trying to find some way of removing the icon/logo from the action bar but the only thing I've found after an hour of searching SO, Android's documentation and Google is how to remove the title bar in whole. That is not what I want. Only want to remove the icon/logo from the title bar.
Any one know how to accomplish this? Preferably I'd like to do this in XML.
Add the following code in your action bar styles:
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item> <!-- This does the magic! -->
PS: I'm using Actionbar Sherlock and this works just fine.
If you do not want the icon in particular activity.
getActionBar().setIcon(
new ColorDrawable(getResources().getColor(android.R.color.transparent)));
If you've defined android:logo="..." in the <application> tag of your AndroidManifest.xml, then you need to use this stuff to hide the icon:
pre-v11 theme
<item name="logo">#android:color/transparent</item>
v11 and up theme
<item name="android:logo">#android:color/transparent</item>
The use of these two styles has properly hidden the action bar icon on a 2.3 and a 4.4 device for me (this app uses AppCompat).
This worked for me
getActionBar().setDisplayShowHomeEnabled(false);
Calling
mActionBar.setDisplayHomeAsUpEnabled(true);
in addition to,
mActionBar.setDisplayShowHomeEnabled(false);
will hide the logo but display the Home As Up icon. :)
Be aware that:
<item name="android:icon">#android:color/transparent</item>
Will also make your options items transparent.
//disable application icon from ActionBar
getActionBar().setDisplayShowHomeEnabled(false);
//disable application name from ActionBar
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setIcon(android.R.color.transparent);
This worked for me.
Remove or show the title using:
getActionBar().setDisplayShowTitleEnabled(true);
Remove or show the logo using:
getActionBar().setDisplayUseLogoEnabled(false);
Remove all:
getActionBar().setDisplayShowHomeEnabled(false);
you can also add below code in AndroidManifest.xml.
android:icon="#android:color/transparent"
It will work fine.
But I found that this gives a problem as the launcher icon also become transparent.
So I used:
getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
and it worked fine.
But if you are having more than one activity and want to make the icon on an activity transparent then the previous approach will work.
I used this and it worked for me.
getActionBar().setIcon(
new ColorDrawable(getResources().getColor(android.R.color.transparent)));
getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
getActionBar().setDisplayHomeAsUpEnabled(true);
I think the exact answer is: for api 11 or higher:
getActionBar().setDisplayShowHomeEnabled(false);
otherwise:
getSupportActionBar().setDisplayShowHomeEnabled(false);
(because it need a support library.)
go to your manifest an find the application tag
android:icon="#android:color/transparent"// simply add this on place of your icon
.....
...
...
Qiqi Abaziz's answer is ok, but I still struggled for a long time getting it to work with the compatibility pack and to apply the style to the correct elements. Also, the transparency-hack is unneccessary. So here is a complete example working for v8 and up:
values\styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyActivityTheme" parent="#style/Theme.AppCompat">
<item name="actionBarStyle">#style/NoLogoActionBar</item> <!-- pre-v11-compatibility -->
<item name="android:actionBarStyle">#style/NoLogoActionBar</item>
</style>
<style name="NoLogoActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="displayOptions">showHome</item> <!-- pre-v11-compatibility -->
<item name="android:displayOptions">showHome</item>
</style>
</resources>
AndroidManifest.xml (shell)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>
<application android:theme="#android:style/Theme.Light.NoTitleBar">
<activity android:theme="#style/PentActivityTheme"/>
</application>
</manifest>
Go in your manifest and find the your activity then add this code:
android:theme="#android:style/Theme.NoTitleBar"
above line hide your Actionbar .
If you need to other feature you can see other options with (CLR + SPC).
The fastest way is to modify your Manifest.xml.
If for example you want to remove the logo of activity "Activity", and leave the logo in other activities, you can do the following:
<activity
android:name=".home.XActivity"
android:logo="#android:color/transparent"
android:configChanges="orientation|keyboardHidden" />
<activity
android:name=".home.HomeActivity"
android:configChanges="orientation|keyboardHidden" />
None of the above worked.
But this did the trick:
override fun onCreate() {
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
toolbar.logo = null
(removed icon from toolbar)

Categories

Resources