当前位置: 首页>>代码示例>>Java>>正文


Java Typeface.SANS_SERIF属性代码示例

本文整理汇总了Java中android.graphics.Typeface.SANS_SERIF属性的典型用法代码示例。如果您正苦于以下问题:Java Typeface.SANS_SERIF属性的具体用法?Java Typeface.SANS_SERIF怎么用?Java Typeface.SANS_SERIF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.graphics.Typeface的用法示例。


在下文中一共展示了Typeface.SANS_SERIF属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
			}
		}
	}
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:23,代码来源:TextAppearance.java

示例2: 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;
    }
}
 
开发者ID:jajasuperman,项目名称:HexColorTime,代码行数:16,代码来源:Wallpaper.java

示例3: 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);
    }
 
开发者ID:ceji-longquan,项目名称:ceji_android,代码行数:29,代码来源:Configuration.java

示例4: 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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:SwitchCompat.java

示例5: 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();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:45,代码来源:TextViewUtil.java

示例6: 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);


}
 
开发者ID:monolifed,项目名称:mininoteview,代码行数:33,代码来源:TextEdit.java

示例7: 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);
}
 
开发者ID:rosenpin,项目名称:QuickDrawEverywhere,代码行数:31,代码来源:DrawView.java

示例8: showDialog

/**
 * 显示自定义对话框
 */
private void showDialog(String message, final boolean isNew) {
	if (color == 0) {
		color = getResources().getColor(R.color.yellow);
	}
	if (typeface == null) {
		typeface = Typeface.SANS_SERIF;
	}
	final AlertDialog.Builder builder = new AlertDialog.Builder(context);
	View view = View.inflate(context, R.layout.layout_dialog, null);
	final EditText editText = (EditText) view.findViewById(R.id.dialog_edittext);
	TextView ok = (TextView) view.findViewById(R.id.tv_ok);
	// ColorTagImageView colorTagImageView = (ColorTagImageView)
	// view.findViewById(R.id.color_tag);
	// colorTagImageView.setListener(new
	// ColorTagImageView.OnColorTagChanges() {
	// @Override
	// public void onColorChange(int color) {
	// editText.setTextColor(color);
	// colors[0] = color;
	// }
	// });
	builder.setView(view);
	editText.setText(content);
	editText.setSelection(content.length());
	builder.setCancelable(false);
	final AlertDialog dialog = builder.show();
	ok.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			content = editText.getText().toString();
			if (TextUtils.isEmpty(content)) {
				textView.setX(0);
				textView.setY(0);
				textView.setText(getResources().getString(R.string.editor_video_sub));
				// Toast.makeText(context, "您没有任何输入!",
				// Toast.LENGTH_SHORT).show();
				dialog.dismiss();
			} else {
				if (isNew) {
					addTextView(null, currentX, currentY, content, color, textSize, rotate, typeface);
				} else {
					addTextView(textView, textView.getX(), textView.getY(), content, color, textView.getTextSize(),
							textView.getRotation(), typeface);
				}
			}
			dialog.dismiss();
		}
	});

	// cancel.setOnClickListener(new OnClickListener() {
	// @Override
	// public void onClick(View v) {
	// dialog.dismiss();
	// }
	// });
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:59,代码来源:MyRelativeLayout.java

示例9: 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 );
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:6,代码来源:SystemFontResolver.java

示例10: 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();
    }
}
 
开发者ID:rosenpin,项目名称:QuickDrawEverywhere,代码行数:74,代码来源:DrawView.java


注:本文中的android.graphics.Typeface.SANS_SERIF属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。