本文整理汇总了Java中android.graphics.Typeface.SERIF属性的典型用法代码示例。如果您正苦于以下问题:Java Typeface.SERIF属性的具体用法?Java Typeface.SERIF怎么用?Java Typeface.SERIF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.graphics.Typeface
的用法示例。
在下文中一共展示了Typeface.SERIF属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureTypeface
/**
* Ensures that the typeface is initialized (if possible).
*/
private void ensureTypeface() {
if (mTypeface == null || mInvalidateTypeface) {
this.mInvalidateTypeface = false;
if (!TextUtils.isEmpty(mFontFamily)) {
this.mTypeface = Typeface.create(mFontFamily, mTextStyle);
} else {
switch (mTypefaceIndex) {
case SANS_SERIF:
this.mTypeface = Typeface.SANS_SERIF;
break;
case SERIF:
this.mTypeface = Typeface.SERIF;
break;
case MONOSPACE:
this.mTypeface = Typeface.MONOSPACE;
break;
}
}
}
}
示例2: ImageTextView
public ImageTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ImageTextView, defStyleAttr, 0);
mText = "";
mText = array.getString(R.styleable.ImageTextView_text);
mTextSize = array.getDimension(R.styleable.ImageTextView_textSize, 10.0f);
int id = array.getResourceId(R.styleable.ImageTextView_bitmap, R.drawable.default_album);
mBitmap = BitmapFactory.decodeResource(context.getResources(), id);
array.recycle();
paint.setAntiAlias(true);
if (mBitmap != null) {
shader = new BitmapShader(mBitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
}
typeface = Typeface.SERIF;
}
示例3: getTypeface
private Typeface getTypeface() {
String textTypeface = PreferenceManager.getDefaultSharedPreferences(getBaseContext()).getString("textTypeface", "1");
switch (Integer.parseInt(textTypeface)) {
default:
return Typeface.DEFAULT;
case 2:
return Typeface.DEFAULT_BOLD;
case 3:
return Typeface.MONOSPACE;
case 4:
return Typeface.SANS_SERIF;
case 5:
return Typeface.SERIF;
}
}
示例4: getChatFont
public Typeface getChatFont() {
if (mCachedFont != null)
return mCachedFont;
String font = mPreferences.getString(PREF_CHAT_FONT, "default");
if (ListWithCustomSetting.isPrefCustomValue(font)) {
File file = ListWithCustomSetting.getCustomFile(mContext, PREF_CHAT_FONT, font);
try {
mCachedFont = Typeface.createFromFile(file);
return mCachedFont;
} catch (Exception ignored) {
}
}
if (font.equals("monospace"))
return Typeface.MONOSPACE;
else if (font.equals("serif"))
return Typeface.SERIF;
else
return Typeface.DEFAULT;
}
示例5: aktivitetOnCreate
public void aktivitetOnCreate(Basisaktivitet ctx) {
ctx.getResources().updateConfiguration(App.sprogKonfig, null);
// Forgrundsinitialisering der skal ske før app'en bliver synlig første gang
// - muligvis aldrig hvis app'en kun betjenes via levende ikon, eller kun er aktiv i baggrunden
if (App.color!=null) return; // initialisering allerede sket
App.color = new DRFarver();
accessibilityManager = (AccessibilityManager) ctx.getSystemService(Context.ACCESSIBILITY_SERVICE); // tager tid i test
skrift_gibson = Typeface.DEFAULT;
skrift_gibson_fed = Typeface.DEFAULT_BOLD;
skrift_georgia = Typeface.SERIF;
skrift_gibson_fed_span = new EgenTypefaceSpan("Gibson fed", App.skrift_gibson_fed);
AppOpdatering.APK_URL = res.getString(R.string.AppOpdatering_APK_URL);
if (!EMULATOR) AppOpdatering.tjekForNyAPK(ctx);
Log.d("onCreate tog " + (System.currentTimeMillis() - TIDSSTEMPEL_VED_OPSTART) + " ms");
}
示例6: getFontFamily
private FontFamily getFontFamily(String fontKey, String defaultVal) {
String fontFace = settings.getString(fontKey, defaultVal);
if (!fontCache.containsKey(fontFace)) {
// TODO add font
if ("gen_book_bas".equals(fontFace)) {
fontCache.put(fontFace,
loadFamilyFromAssets(fontFace, "GentiumBookBasic"));
} else {
Typeface face = Typeface.SANS_SERIF;
if ("sans".equals(fontFace)) {
face = Typeface.SANS_SERIF;
} else if ("serif".equals(fontFace)) {
face = Typeface.SERIF;
} else if ("mono".equals(fontFace)) {
face = Typeface.MONOSPACE;
} else if ("default".equals(fontFace)) {
face = Typeface.DEFAULT;
}
fontCache.put(fontFace, new FontFamily(fontFace, face));
}
}
return fontCache.get(fontFace);
}
示例7: setSwitchTypefaceByIndex
private void setSwitchTypefaceByIndex(int typefaceIndex, int styleIndex) {
Typeface tf = null;
switch (typefaceIndex) {
case 1:
tf = Typeface.SANS_SERIF;
break;
case 2:
tf = Typeface.SERIF;
break;
case 3:
tf = Typeface.MONOSPACE;
break;
}
setSwitchTypeface(tf, styleIndex);
}
示例8: setFontTypeface
/**
* Sets the font typeface for a {@link TextView}.
*
* @param textview text view instance
* @param typeface one of @link Component#TYPEFACE_DEFAULT},
* {@link Component#TYPEFACE_SERIF},
* {@link Component#TYPEFACE_SANSSERIF} or
* {@link Component#TYPEFACE_MONOSPACE}
* @param bold true for bold, false for not bold
* @param italic true for italic, false for not italic
*/
public static void setFontTypeface(TextView textview, int typeface,
boolean bold, boolean italic) {
Typeface tf;
switch (typeface) {
default:
throw new IllegalArgumentException();
case Component.TYPEFACE_DEFAULT:
tf = Typeface.DEFAULT;
break;
case Component.TYPEFACE_SERIF:
tf = Typeface.SERIF;
break;
case Component.TYPEFACE_SANSSERIF:
tf = Typeface.SANS_SERIF;
break;
case Component.TYPEFACE_MONOSPACE:
tf = Typeface.MONOSPACE;
break;
}
int style = 0;
if (bold) {
style |= Typeface.BOLD;
}
if (italic) {
style |= Typeface.ITALIC;
}
textview.setTypeface(Typeface.create(tf, style));
textview.requestLayout();
}
示例9: initConfig
private void initConfig()
{
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
showBottomBarFlag = sharedPreferences.getBoolean(getString(R.string.prefShowButtonsKey), true);
fontSize = sharedPreferences.getFloat(getString(R.string.prefFontSizeKey), fontSize);
filepath = Environment.getExternalStorageDirectory().getAbsolutePath();
String typefaceString = sharedPreferences.getString(getString(R.string.prefTypefaceKey), "DEFAULT");
if(typefaceString.equalsIgnoreCase("DEFAULT"))
{
mTypeface = Typeface.DEFAULT;
}
else if(typefaceString.equalsIgnoreCase("MONOSPACE"))
{
mTypeface = Typeface.MONOSPACE;
}
else if(typefaceString.equalsIgnoreCase("SANS_SERIF"))
{
mTypeface = Typeface.SANS_SERIF;
}
else if(typefaceString.equalsIgnoreCase("SERIF"))
{
mTypeface = Typeface.SERIF;
}
boolean noTitleBarFlag = sharedPreferences.getBoolean(getString(R.string.prefNoTitleBarKey), false);
if(noTitleBarFlag) requestWindowFeature(Window.FEATURE_NO_TITLE);
}
示例10: onRestoreInstanceState
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle) state;
for (int i = 0; i < bundle.getInt("drawMoveHistorySize"); i++) {
mDrawMoveHistory.add((DrawMove) bundle.getSerializable("mDrawMoveHistory" + i));
}
mDrawMoveHistoryIndex = bundle.getInt("mDrawMoveHistoryIndex");
mDrawMoveBackgroundIndex = bundle.getInt("mDrawMoveBackgroundIndex");
mDrawingMode = (DrawingMode) bundle.getSerializable("mDrawingMode");
mDrawingTool = (DrawingTool) bundle.getSerializable("mDrawingTool");
mInitialDrawingOrientation = (DrawingOrientation) bundle.getSerializable("mInitialDrawingOrientation");
mDrawColor = bundle.getInt("mDrawColor");
mDrawWidth = bundle.getInt("mDrawWidth");
mDrawAlpha = bundle.getInt("mDrawAlpha");
mBackgroundColor = bundle.getInt("mBackgroundColor");
mAntiAlias = bundle.getBoolean("mAntiAlias");
mDither = bundle.getBoolean("mDither");
mFontSize = bundle.getFloat("mFontSize");
mPaintStyle = (SerializablePaint.Style) bundle.getSerializable("mPaintStyle");
mLineCap = (SerializablePaint.Cap) bundle.getSerializable("mLineCap");
mFontFamily =
bundle.getInt("mFontFamily") == 0 ? Typeface.DEFAULT :
bundle.getInt("mFontFamily") == 1 ? Typeface.MONOSPACE :
bundle.getInt("mFontFamily") == 2 ? Typeface.SANS_SERIF :
bundle.getInt("mFontFamily") == 3 ? Typeface.SERIF : Typeface.DEFAULT;
state = bundle.getParcelable("superState");
}
super.onRestoreInstanceState(state);
}
示例11: SystemFontResolver
public SystemFontResolver() {
this.defaultFont = new FontFamily("default", Typeface.DEFAULT);
this.serifFont = new FontFamily("serif", Typeface.SERIF);
this.sansSerifFont = new FontFamily("sans-serif", Typeface.SANS_SERIF);
this.monoSpaceFont = new FontFamily("monospace", Typeface.MONOSPACE );
}
示例12: initAttributes
/**
* Initialize view attributes
*
* @param context
* @param attrs
*/
private void initAttributes(Context context, AttributeSet attrs) {
TypedArray typedArray = context.getTheme().obtainStyledAttributes(
attrs, R.styleable.DrawView, 0, 0);
try {
mDrawColor = typedArray.getColor(R.styleable.DrawView_dv_draw_color, Color.BLACK);
mDrawWidth = typedArray.getInteger(R.styleable.DrawView_dv_draw_width, 3);
mDrawAlpha = typedArray.getInteger(R.styleable.DrawView_dv_draw_alpha, 255);
mAntiAlias = typedArray.getBoolean(R.styleable.DrawView_dv_draw_anti_alias, true);
mDither = typedArray.getBoolean(R.styleable.DrawView_dv_draw_dither, true);
int paintStyle = typedArray.getInteger(R.styleable.DrawView_dv_draw_style, 2);
if (paintStyle == 0)
mPaintStyle = SerializablePaint.Style.FILL;
else if (paintStyle == 1)
mPaintStyle = SerializablePaint.Style.FILL_AND_STROKE;
else if (paintStyle == 2)
mPaintStyle = SerializablePaint.Style.STROKE;
int cap = typedArray.getInteger(R.styleable.DrawView_dv_draw_corners, 2);
if (cap == 0)
mLineCap = SerializablePaint.Cap.BUTT;
else if (cap == 1)
mLineCap = SerializablePaint.Cap.ROUND;
else if (cap == 2)
mLineCap = SerializablePaint.Cap.SQUARE;
int typeface = typedArray.getInteger(R.styleable.DrawView_dv_draw_font_family, 0);
if (typeface == 0)
mFontFamily = Typeface.DEFAULT;
else if (typeface == 1)
mFontFamily = Typeface.MONOSPACE;
else if (typeface == 2)
mFontFamily = Typeface.SANS_SERIF;
else if (typeface == 3)
mFontFamily = Typeface.SERIF;
mFontSize = typedArray.getInteger(R.styleable.DrawView_dv_draw_font_size, 12);
isForCamera = typedArray.getBoolean(R.styleable.DrawView_dv_draw_is_camera, false);
int orientation = typedArray.getInteger(R.styleable.DrawView_dv_draw_orientation,
getWidth() > getHeight() ? 1 : 0);
mInitialDrawingOrientation = DrawingOrientation.values()[orientation];
if (getBackground() != null && !isForCamera)
try {
mBackgroundColor = ((ColorDrawable) getBackground()).getColor();
setBackgroundColor(Color.TRANSPARENT);
} catch (Exception e) {
e.printStackTrace();
setBackgroundColor(Color.TRANSPARENT);
mBackgroundColor = ((ColorDrawable) getBackground()).getColor();
setBackgroundResource(R.drawable.drawable_transparent_pattern);
}
else {
setBackgroundColor(Color.TRANSPARENT);
mBackgroundColor = ((ColorDrawable) getBackground()).getColor();
if (!isForCamera)
setBackgroundResource(R.drawable.drawable_transparent_pattern);
}
mBackgroundPaint = new SerializablePaint();
mBackgroundPaint.setStyle(SerializablePaint.Style.FILL);
mBackgroundPaint.setColor(mBackgroundColor != -1 ? mBackgroundColor : Color.TRANSPARENT);
mDrawingTool = DrawingTool.values()[typedArray.getInteger(R.styleable.DrawView_dv_draw_tool, 0)];
mDrawingMode = DrawingMode.values()[typedArray.getInteger(R.styleable.DrawView_dv_draw_mode, 0)];
mZoomEnabled = typedArray.getBoolean(R.styleable.DrawView_dv_draw_enable_zoom, false);
mZoomRegionScale = typedArray.getFloat(R.styleable.DrawView_dv_draw_zoomregion_scale, mZoomRegionScale);
mZoomRegionScaleMin = typedArray.getFloat(R.styleable.DrawView_dv_draw_zoomregion_minscale, mZoomRegionScaleMin);
mZoomRegionScaleMax = typedArray.getFloat(R.styleable.DrawView_dv_draw_zoomregion_maxscale, mZoomRegionScaleMax);
} finally {
typedArray.recycle();
}
}