I have an app where I want the user to be able to select a font. I've already downloaded fonts in the assets folder of the project.
Now I want to merge all the fonts in a ListView.
Then I want to set an onClickListener and want to get the selected font.
I want each line of the ListView to display the font name and the right font for that name.
You can get your fonts with this way
Typeface typeface = Typeface.createFromAsset(context.getAssets(),
"font.ttf");
So whenever user clicked on an item of ListView store name of the font in a shared preferences then you can get selected font with this :
Typeface typeface = Typeface.createFromAsset(context.getAssets(),
PreferenceManager.getDefaultSharedPreferences(context).getString("selected_font_name"));
Related
How to remove this recommendation TAB with previously used email Id that appears when i click on the edit text . Email Tags
How to make that color TRANSPARENT once I've selected one them.Selected Color
You can use this in your xml to disable the auto fill
android:importantForAutofill="no"
if it doesn't work, could you please include your EditText xml
I want to change the font to Century Gothic, I had some explanations and fixing but I got nothing, Im a newbie :) .. like
1 Typeface font = Typeface.createFromAsset(getAssets(), "Century-Gothic.ttf");
2 TextView tv=(TextView) findViewById(R.id.textView0);
3 tv.setTypeface(font);
Please help?
To use custom font for android app follow this steps
1- Add the custom font inside assets folder
2- Define the font
Typeface myfont = Typeface.createFromAsset(context,"myfont.ttf");
Now you can use myfont for textview
mytextview.setTypeface(myfont);
This works for me in android studio 3.1.3:
Copy the font inside font folder.
Select the font on fontFamily attributes.
This is more of a general question, as I am still a beginning in the language of Java. I would like to know how can I make the font or text different? As well as its colour. An example for this is the MSN live messenger, for PC and Mac. In the chatbox, you can change the font and colour of the text, and it is also viewable by others, how can I make it like that for android?
In the assets folder of your project, create a new folder named fonts. Put .ttf files in there. (You can download some here
) These are files that contain fonts. Then, just to give you an idea of how to apply these fonts, here is an example of applying a font to a text view...
myTextView.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/frquad.ttf"));
As for color, use this method...
myTextView.setTextColor();
Hopefully this has been of help.
// Font path
String fontPath = "fonts/fontname.ttf";
// text view label
TextView txt = (TextView) findViewById(R.id.txt);
// Loading Font Face
Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
// Applying font
txt.setTypeface(tf);
Typeface typeFace = Typeface.createFromAsset(
context.getAssets(),
"fonts/" + "abcd.ttf");
textView.setTypeface(typeFace);
change the color:
radio2.setTextColor(Color.parseColor("#bcbddc"));
Sorry for my awful English.
There is an application in android TabHost. Tabs include Activity.
In the application I use the menu compile from prefs.xml
How can I change dynamic font size in activity only??
You can alter text size using this:
int size = 12;
TextView textView = findViewById(R.id.my_text_view);
textView.setTextSize(size);
In my application I have a listview with products. Above the listview in the actionbar I have a button "edit list". When you click on the button I want to add an image to each listviewitem in the listview. When you click on the image you delete it from the list. Now I added an imageview to the listviewitem and set die visibility to gone.
But I don't know how to change the visibility with a click on a button.
So the question: How do you add an imageview in listviewitem with click on button? Or how do you change the visibility property of an imageview in an Listviewitem?
You can use a static parameter like int uiUpdate=0 and use an adapter to add data to list view and check uiUpdate in getView of your adapter. When user click on button set uiUpdate=1 and reffresh your list with this : yourlist.setListAdapter(new EfficientAdapter);
in getView of EfficientAdapter check value of uiUpdate if it's 1 set visibility VISIBLE : yourimageview.setVisibility(View.VISIBLE); efficientAdapter is something like this : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html