logo
down
shadow

Change progressDialog font to custom on Android


Change progressDialog font to custom on Android

Content Index :

Change progressDialog font to custom on Android
Tag : android , By : keird
Date : November 28 2020, 11:01 PM

fixed the issue. Will look into that further What I'm trying to do is to change the font of progressBar message from default to custom. I've already tried many techniques and failed. , Worked like a charm:
 dialog = new ProgressDialog(getContext());
        String message = getContext().getString(R.string.building_route);
        SpannableString spannableString =  new SpannableString(message);

        CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getContext().getAssets(), "fonts/Lato-Regular.ttf"));
        spannableString.setSpan(typefaceSpan, 0, message.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        dialog.setMessage(spannableString);
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dialog.setIndeterminate(true);
        dialog.setCancelable(false);
        dialog.show();

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Change font typeface of ProgressDialog within DialogFragment


Tag : android , By : nonkelhans
Date : March 29 2020, 07:55 AM
will help you One of the suggested solution is as follow. But I don't think this is a good way. Any further suggestion are very much welcomed.
public class ProgressDialogEx extends ProgressDialog {
    public ProgressDialogEx(Context context) {
        super(context);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = this.findViewById(android.R.id.message);
        if (view != null) {
            // Shouldn't be null. Just to be paranoid enough.
            Utils.setCustomTypeface(view, Utils.ROBOTO_LIGHT_FONT);
        }
    }
}
public class LoadFromCloudTaskFragment extends DialogFragment {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        this.progressDialog = new ProgressDialogEx(this.getActivity());
        this.progressDialog.setMessage(progressMessage);
        this.progressDialog.setCanceledOnTouchOutside(false);

        return progressDialog;
    }
public static final Typeface ROBOTO_LIGHT_TYPE_FACE = Typeface.createFromAsset(MyApplication.instance().getAssets(), "fonts/Roboto-Light.ttf");

public static void setCustomTypeface(View view, Typeface typeFace) {
    if (view instanceof TextView) {
        ((TextView)view).setTypeface(typeFace);
    } else if (view instanceof EditText) {
        ((EditText)view).setTypeface(typeFace);
    } else if (view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup)view;
        int count = viewGroup.getChildCount();
        for (int i = 0; i < count; i++) {
            setCustomTypeface(viewGroup.getChildAt(i), typeFace);
        }
    }
}

How to change the font color for custom buttons in an Android app?


Tag : android , By : dexteryy
Date : March 29 2020, 07:55 AM
it should still fix some issue I am using a custom button class to use a custom font for all the buttons in my app. I would like to change the color too but I don't know how. It is probably pretty easy but I couldn't figure it out. , Try use setTextColor(Color.BLUE);
private void init() {
        if (!isInEditMode()) {
            Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "MyCustomFont.otf");
            setTypeface(tf);
            setTextColor(Color.BLUE);
        }
    }

How to change the ProgressDialog Message font size in android programmatically?


Tag : android , By : deanschang
Date : March 29 2020, 07:55 AM
Hope this helps Change the ProgressDialog Message font size in android programmatically:
String s= "Hello";
String title="MyTitle";

SpannableString ss1=  new SpannableString(title);
ss1.setSpan(new RelativeSizeSpan(2f), 0, ss1.length(), 0);  
ss1.setSpan(new ForegroundColorSpan(Color.RED), 0, ss1.length(), 0); 
SpannableString ss2=  new SpannableString(s);
ss2.setSpan(new RelativeSizeSpan(2f), 0, ss2.length(), 0);  
ss2.setSpan(new ForegroundColorSpan(Color.GREEN), 0, ss2.length(), 0); 

ProgressDialog pd = new ProgressDialog(this);
pd.setTitle(ss1);
pd.setMessage(ss2);
pd.show();

Can I change the output font of an Android custom keyboard?


Tag : android , By : user133629
Date : March 29 2020, 07:55 AM
I wish did fix the issue. changing the font style inside the application.
create a simple class named
import java.lang.reflect.Field;
import android.content.Context;
import android.graphics.Typeface;

public final class FontsOverride {

public static void setDefaultFont(Context context,
        String staticTypefaceFieldName, String fontAssetName) {
    final Typeface regular = Typeface.createFromAsset(context.getAssets(),
            fontAssetName);
    replaceFont(staticTypefaceFieldName, regular);
}

protected static void replaceFont(String staticTypefaceFieldName,
        final Typeface newTypeface) {
    try {
        final Field staticField = Typeface.class
                .getDeclaredField(staticTypefaceFieldName);
        staticField.setAccessible(true);
        staticField.set(null, newTypeface);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    }
}
public final class Application extends android.app.Application {
    @Override
    public void onCreate() {
        super.onCreate();
        FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/GeezEdit.ttf");
        FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/GeezEdit.ttf");
        /*FontsOverride.setDefaultFont(this, "MONOSPACE", "MyFontAsset2.ttf");
        FontsOverride.setDefaultFont(this, "SERIF", "MyFontAsset3.ttf");
        FontsOverride.setDefaultFont(this, "SANS_SERIF", "MyFontAsset4.ttf");*/
    }
}
<item name="android:typeface">monospace</item>
android:name=".Application"

How to change Custom Font of Android Menu Item?


Tag : android , By : Karina
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How to adjust text font size to fit textview
  • "Android 2.x" vs "Google APIs" for Android AVD Setup
  • How to center buttons on screen horizontally and vertically plus equidistant apart?
  • Discrete seekbar in Android app?
  • Gradle Build Fails - Illegal exception table range in class file com/google/wireless/android/sdk/stats/GradleBuildMemory
  • register has type Long (High Half) but expected Long (Low Half)
  • Is it good idea to use Dispatcher.Main with delay( )?
  • WebView and Advanced View is Not loading partiucalr URL
  • How to show three dots at the end of text view
  • Is it possible to run macros within Android Studio project?
  • Adding a button with default appearance but changed background color
  • What is best way to show notification at a certain time in Android?
  • Jetifier not working when library uses android component and app uses androidx component
  • How can I write the contents of an image in a filesystem
  • Retrieve a list of images from the Database and display them using a ListView?
  • java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
  • Timer/hourglass wont stop
  • How can I make AndroidX the default library for new Android projects?
  • Is it okay to delete buildToolsVersion android studio because of a warning in the Asyncstorage library?
  • Can I call a class that doesn't have an activity withIntent?
  • Android TextView fontFamily not working when set via TextAppearance
  • Unable to find nearby places
  • Is there any way to launch my application right away without 'Ok Google"?
  • Places api set location biased based on current location
  • Layout Preview is not displaying layout when Material Design is added
  • How do I resolve this diamond problem in Kotlin?
  • How to update the custom value in a view model object
  • How to stop refreshing/re-creating activity when updating Firebase data using setValue?
  • Manifest Permissions vs App Setttings Permissions
  • NumberFormatException in Try-Catch while converting String to Int
  • How to pass observable fields through include tag?
  • Next button on Android keyboard not submitting form
  • Does Firestore support automatic functions for updates?
  • Why app crashing because of a missing dimension (for google maps) only when I apply changes?
  • How to make a grouping, ordering and sorting: Kotlin collection
  • how to use augmented reality to change the color of a qr code once it is detected using with arcore and ml kit firebase
  • how to resolve Firebase projects adding quota problem?
  • Why it Kotlin giving me the wrong Int value when converting from a String
  • How to add bottom navigation listeners to fragments
  • Why is scrollview hiding buttons behind other views?
  • Open Settings using Linking.sendIntent()
  • How do I access an unknown node in firebase while retrieving data?
  • Can't retrieve list of all users from firebase authetication
  • many activities with same content (adview, reward adview, functions...) how to avoid repeating code?
  • Popup doesn't hide when touch outside
  • proper way to handling images in Android? by using Firebase
  • Android: Button is faded gray when it should be transparent
  • Gradle DSL method not found: 'deleteAllActions()'
  • In Clean Architecture, must Repository is Android or Kotlin module?
  • Kotlin parse double from string
  • Inconsistency detected. Invalid view holder adapter positionViewHolder
  • In App Update API always returns 1 (UPDATE_NOT_AVAILABLE)
  • Event of ImageView when click
  • Basic precautions to prevent piracy?
  • What is the difference between 'center' and 'centerCrop' in the "ImageView"?
  • Unable to receive SIP calls when app is killed
  • Android emulator not processing http get request, but iOS simulator works fine
  • Android Problem with sharing temporary file
  • How to add Broadcast in Android?
  • How to hide 'Running in Chrome' toast on TWA application on Android devices?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com