Here's my code for the custom dialog box I've implemented
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("This is the Title");
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setTypeface(Typeface.createFromAsset(getAssets(),
"fonts/Barkentina.otf"));
I'm easily able to change the font of the text inside dialogue box. But what can I do to change the font of dialog title?
If you want to override the font in your entire application then you can follow this answer.
As per your approach you can follow this answer which uses R.id.alertTitle to find the alter dialog title id. Then you can set typeface to the TextView with the id.
Related
I am trying to set my alert dialog box Title size and title bar size for which I am not using any text box or theme to display my title name .I am using the following code to set my title name, title background and font color:-
CODE-
#Override
public boolean onLongClick(View arg0)
{
custom = new Dialog(Activity_AddItem.this);
custom.setTitle("Selected Product");
custom.getWindow().setBackgroundDrawableResource(R.color.button_color);
custom.getWindow().setTitleColor(Color.WHITE);
custom.show();
return false;
}
Snapshot
Is there any way to change the titlebar size and title font size without using theme or style or text box?
If you use the default implementation of a dialog no, you cannot change those sizes but you can if you create a custom dialog:
-Create a layout for the dialog(title, content, buttons etc)
-inflate that layout into a view
-create a dialog and instead of
dialog.setTitle(...);
dialog.setMessage(...);
etc...
do
dialog.setView(yourcustomview);
this way you have total control over the size of each view in you dialog
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 Text view in hyperlink,when i click the link i want to open the alert dialog.
How to do this.i knew Separately to create the Alert dialog ,but using hyperlink am getting struggle.
My code
policy.setText(Html.fromHtml("<a href>PasswordPolicy</a> "));
This involves a little trick, Use underline tag in strings.xml like below
<string name="tvideo"><u>Video</u></string>
Now set this in your TextView in the .xml
and setonclicklistener to that TextView and open your dialog.
Also note that output will be seen during run-time. I'm afraid it will not be visible in Graphical Layout.
for that you need to create custom dialog and its text property as linkify.
TextView myWebSite = new TextView(this);
myWebSite .setText("http://http://www.google.com/");
Linkify.addLinks(myWebSite , Linkify.WEB_URLS);
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 working on an android application that allows user to add an edit text dynamically. I have been able to add the edit text using an alert dialog. But I need to make the dialog box transparent .I need to be able to see the imageview in the background. Color.Transparent wont work because my background is an image
Try this:
Dialog mDialog = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
or
mDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
You can try this
<EditText
android:id="#+id/purpose_textfield"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#null"/>
Instead of Using alert Dialog Box, i prefer you to use Dialog box:
And use this code:
Dialog dialog = new Dialog(getBaseContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);