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.
Related
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.
I created custom dialog to get input from users extending DialogPreferences class for setting. i need to change font used in dialog and external font using typeface. i set the font to massage using following code. but i couldn't set it for title because i couldn't find the title view also buttons( id of title and buttons).
Text View message = (Text View)view.findViewById(android.R.id.message);
message.setTypeface(font);
how can i do this?
thank you.
I have a dialog that comes up in my app and I wanted to stray away from using the default dialog, to give something slightly more customized. In my dialog layout, I included the following:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#drawable/My_Custom_Background">
This does basically what I want it to, it changes the background as expected. However, this only applies to the layout of the contents of the dialog box: the dialog also has a title and the title part of the dialog box is still the default Android theme, then everything under it is customized as I wanted. Is there away to extend the custom background to the entire dialog box?
You need to remove the title bar
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dialog);
Make sure to call requestWindowFeature() before the setContentView() otherwise you get a FATAL EXCEPTION
you can create your dialog as below
Dialog mDialog = new Dialog(mContext);
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
mDialog.setContentView(R.layout.your_custom_dialog_layout);
mDialog.setCancelable(false);
mDialog.show();
and inside your custom layout, you can set the custom drawable as a background.
An alternate is to remove your dialog titlebar using this...
yourdialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
and design whole dialog with title inside your layout...
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 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