I would like to change the font of a RichTextField but I want to change it after the initialization of the Field.
Is it possible?
Font font = Font.getDefault() ;
FontFamily ff;
try
{
ff = FontFamily.forName("arial");
font = ff.getFont(FontFamily.SCALABLE_FONT, 18).derive(Font.BOLD);
field.setFont(font);
}
catch(ClassNotFoundException e)
{
}
If you can obtain the reference to the RichTextField, you can call setFont(Font font) on it, and then call invalidate() to force the field to repaint itself. invalidate() is a protected method, so you're going to have to modify your RichTextField class (extend it) to either update setFont to automatically call invalidate, or provide a public version of invalidate that you can call.
other way...
try {
myFontFamily = FontFamily.forName("BBAlpha Serif");
Font appFont = myFontFamily.getFont(Font.PLAIN, 6, Ui.UNITS_pt);
field.setFont(appFont );
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Related
I have need to modify and customize the Entry Control in Xamarin, but I have difficulty setting, or rather to find the method for declaring the height of the control of Xamarin ios.
How can I do ? here is my code.
[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace MyApplication.iOS
{
public class MyEntryRenderer : EntryRenderer
{
//CUSTOM entry RENDER IOS
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.BackgroundColor = UIColor.FromRGB(43, 50, 58);
Control.TextColor = UIColor.FromRGB(255, 255, 255);
//Control.Height ???
}
}
}
}
There's a HeightRequest property on the cross-platform Entry class. Why not set it there and let Xamarin's renderer do the work?
If you want to set it directly in your own renderer try
Control.Frame = new CGRect(0, 0, width, height);
You can set this on PCL/shared side.
public MyEntry()
{
this.HeightRequest = 50;
}
When I add navigationContent and actionContent on the actionBar in flex mobile application, I get visible border, I need to know how to remove it.
Thanks,
You should make your own ActionBarButtonSkin and override this method:
override protected function get border():DisplayObject
{
// TODO Auto Generated method stub
var border:DisplayObject = super.border;
border.alpha = 0;
return border;
}
How can I change the font color of a text in black berry?
try this -
LabelField l = new LabelField("hello") {
protected void paint(Graphics g) {
g.setColor(0x0511a0a); //here you can add any colors. either color codes (like - 0x0511a0a) or like this- Color.RED
super.paint(g);
}
};
I'm beginner in BB dev. I create a CustomListField and when I click on a row, the background color of this row must change and a new screen must be displayed (it's done!).
Could any one please help me to get this done?
thx
Below is the code:
protected boolean navigationClick(int status, int time)
{Field field = this.getLeafFieldWithFocus();
if(field instanceof ListField)
{
// listValues is String[] where you store your list elements.
// listField is the ListField instance you are using
UiApplication.getUiApplication().pushScreen(new ReadMsgScreen());
int index= getIndex();
if(index== this.getSelectedIndex())
{
**// I think the code to change the row's background color must be set here!**
}
return true;
}
return super.navigationClick(status, time);
}
use this it will definately work...
int tmpcolor = graphics.getColor();
graphics.setColor(Color.CYAN);
graphics.fillRect(0, y, width, getRowHeight());
graphics.setColor(tmpcolor);
thanks...
onerride the paint() method in blackberry as showed the code below..
_specialNumbers = new LabelField(Constants.SPECIAL_NUMBERS,LabelField.USE_ALL_WIDTH) {
protected void paintBackground(Graphics arg0) {
int color = arg0.getBackgroundColor();
arg0.setBackgroundColor(Color.LIGHTGREY);
arg0.clear();
arg0.setBackgroundColor(color);
}
};
In the drawListRow() method of the ListFieldCallback for your CustomListField draw that selected line differently and call a Transition to display the other Screen slowly.
Right now I'm setting a font to my application, but I was just following an example. How can I know what fonts I have available to me?
FontFamily alphaSansFamily;
try {
alphaSansFamily = FontFamily.forName("BBAlpha Serif");
Font appFont = alphaSansFamily.getFont(Font.PLAIN, 9,
Ui.UNITS_pt);
setFont(appFont);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Thanks!
You can use FontFamily.getFontFamilies() to get a list of all fonts on the device.