I declared a dialog activity in my Manifest as follows:
<activity android:name=".myDialog"
android:label="#string/title_dlg"
android:icon="#android:drawable/ic_dialog_alert"
android:exported="false"
android:excludeFromRecents="true"
android:theme="#android:style/Theme.Dialog">
However, only the title's text appears in the title bar and the icon appears to be ignored.
Is there a way to also show the icon in the title bar?
Use this after your super.onCreate(savedInstanceState); call:
requestWindowFeature(Window.FEATURE_LEFT_ICON);
Then, set your contentView(R.layout.youLayout);
and then use this:
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);
The order is important.
I think using below line after super call will work
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
Keep in mind to place it before setting content view
Related
I want to remove this unwanted title bar
I cant remove this
i have tried
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
This is not a title bar. This is ActionBar or Toolbar. You should extend your application theme from Theme.AppCompat.NoActionBar. Or just add android:theme="#style/Theme.AppCompat.NoActionBar" to <application/> tag in AndroidManifest.xml
add the following to your manifest:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
That should sort it, replace Theme with your actual theme if required, this line goes within the application part of the manifest or can go where the activity is declared.
You need to set your content view AFTER you have written the two lines
//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.layout_name);
I am able to customize the Window title bar and its icon by following the below Link :-
http://androidcodesnippetsblog.blogspot.in/2013/03/custom-window-title-bar-in-android.html
But I want to have different title for different activities running in the same project.Is there any way to fix from one particular xml to have title bar and icon for multiple activities.
just Set imageview and textview id in your custom layout and set dynamically its value in particular Activity
ImageView image=(Imageview)getWindow().findViewById(your image view id);
TextView title=(Textview)getWindow().findViewById(your image view id);
set image.setImageResource(...);
and title.settext(title);
Thats it....
Instead of having the theme on your application tag change it to your activity instead. For example:
<activity
android:theme="#style/themeForAcitivy"
android:name="MyActivity">
</activity>
You can also call getActionBar().setCustomView(R.layout.myCustomBar) on each activity to create a custom ActionBar view if that works for you too.
How to access the title of the dialog to change the typeface font ( to create a custom title of dialog) ?
You can't do it. You must use a activity and set its theme to dialog. like this
<activity android:theme="#android:style/Theme.Dialog" />
when you start your activity it's start as a dialog and setTypeFace in your xml layout file or set it programmatically. If you don't want to have a Title set this code :
requestWindowFeature(Window.FEATURE_NO_TITLE);
It'll need to be done immediately after calling super.onCreate.
I am new to implement the ListView with section.
I have use this application to implement the section to my list view.
Now I want to add the Titlebar that display the application page title. Then where do I have to make a change? In the xml file or in the Java file?
Please refer the example and let me tell what should I have to change to make Titlebar for my app.
Try this...
final Activity activity = this;
activity.setTitle("Settings");
if you disabled the title bar using, this.requestWindowFeature(Window.FEATURE_NO_TITLE);
remove it.
(OR)
Try this..
final Activity activity = this;
this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.settings);
activity.setTitle("Settings");
There are two ways to change title bar for your activity:
Design time (that is, change title in AndroidManifest.xml file).
By coding (that is, you can code to change the activity title).
Example for 1st:
you can Change the Title of each screen (i.e. Activity) by setting their Android:label inside the AndroidManifest.xml file:
<activity android:name=".Hello_World"
android:label="This is the Hello World Application">
</activity>
And yes, to display customized title bar for your activity, go through this answer: How to change the text on the action bar
In your AndroidManifest.xml file you have a section for each activity that looks like this
<activity
android:label="Your Activity"
android:name=".YourActivity" />
where the android:label tag defines what the text in the titlebar is.
I have develop app in which I set layout 480 * 320, it is starting from top. But my problem is there is one in build border are display when we take a new project and it is display in all activity. So I want to disable it.
Border like
So can you tell how can I remove it or hide it?
I think what you are trying to do is hide the TitleBar of the application. You can do that by changing the application theme.
Add android:theme="#android:style/Theme.Light.NoTitleBar" in the <application> tag of your manifest file.
Any theme with .NoTitleBar should do the trick.
use any one.
Manifest:
android:theme="#android:style/Theme.NoTitleBar"
Or
java:
requestWindowFeature(Window.FEATURE_NO_TITLE);
requestFeature(FEATURE_NO_TITLE);
in you activity's onCreate before setting the layout should remove it.
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);