本文整理汇总了Java中com.cengalabs.flatui.FlatUI.getFont方法的典型用法代码示例。如果您正苦于以下问题:Java FlatUI.getFont方法的具体用法?Java FlatUI.getFont怎么用?Java FlatUI.getFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cengalabs.flatui.FlatUI
的用法示例。
在下文中一共展示了FlatUI.getFont方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.cengalabs.flatui.FlatUI; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
if (attributes == null)
attributes = new Attributes(this, getResources());
if (attrs != null) {
// getting android default tags for textColor and textColorHint
String textColorAttribute = attrs.getAttributeValue(FlatUI.androidStyleNameSpace, "textColor");
int styleId = attrs.getStyleAttribute();
int[] attributesArray = new int[] { android.R.attr.textColor };
TypedArray styleTextColorTypedArray = getContext().obtainStyledAttributes(styleId, attributesArray);
// color might have values from the entire integer range, so to find out if there is any color set,
// checking if default value is returned is not enough. Thus we get color with two different
// default values - if returned value is the same, it means color is set
int styleTextColor1 = styleTextColorTypedArray.getColor(0, -1);
int styleTextColor2 = styleTextColorTypedArray.getColor(0, 1);
hasOwnTextColor = textColorAttribute != null || styleTextColor1 == styleTextColor2;
styleTextColorTypedArray.recycle();
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.fl_FlatTextView);
// getting common attributes
int customTheme = a.getResourceId(R.styleable.fl_FlatTextView_fl_theme, Attributes.DEFAULT_THEME);
attributes.setThemeSilent(customTheme, getResources());
attributes.setFontFamily(a.getString(R.styleable.fl_FlatTextView_fl_fontFamily));
attributes.setFontWeight(a.getString(R.styleable.fl_FlatTextView_fl_fontWeight));
attributes.setFontExtension(a.getString(R.styleable.fl_FlatTextView_fl_fontExtension));
attributes.setRadius(a.getDimensionPixelSize(R.styleable.fl_FlatTextView_fl_cornerRadius, Attributes.DEFAULT_RADIUS_PX));
attributes.setBorderWidth(a.getDimensionPixelSize(R.styleable.fl_FlatTextView_fl_borderWidth, 0));
// getting view specific attributes
textColor = a.getInt(R.styleable.fl_FlatTextView_fl_textColor, textColor);
backgroundColor = a.getInt(R.styleable.fl_FlatTextView_fl_backgroundColor, backgroundColor);
customBackgroundColor = a.getInt(R.styleable.fl_FlatTextView_fl_customBackgroundColor, customBackgroundColor);
a.recycle();
}
GradientDrawable gradientDrawable = new GradientDrawable();
if (backgroundColor != Attributes.INVALID) {
gradientDrawable.setColor(attributes.getColor(backgroundColor));
} else if (customBackgroundColor != Attributes.INVALID) {
gradientDrawable.setColor(customBackgroundColor);
} else {
gradientDrawable.setColor(Color.TRANSPARENT);
}
gradientDrawable.setCornerRadius(attributes.getRadius());
gradientDrawable.setStroke(attributes.getBorderWidth(), attributes.getColor(textColor));
setBackgroundDrawable(gradientDrawable);
// setting the text color only if there is no android:textColor attribute used
if (!hasOwnTextColor) setTextColor(attributes.getColor(textColor));
// check for IDE preview render
if(!this.isInEditMode()) {
Typeface typeface = FlatUI.getFont(getContext(), attributes);
if (typeface != null) setTypeface(typeface);
}
}
示例2: init
import com.cengalabs.flatui.FlatUI; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
if (attributes == null)
attributes = new Attributes(this, getResources());
if (attrs != null) {
// getting android default tags for textColor and textColorHint
hasOwnTextColor = attrs.getAttributeValue(FlatUI.androidStyleNameSpace, "textColor") != null;
hasOwnHintColor = attrs.getAttributeValue(FlatUI.androidStyleNameSpace, "textColorHint") != null;
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.fl_FlatEditText);
// getting common attributes
int customTheme = a.getResourceId(R.styleable.fl_FlatEditText_fl_theme, Attributes.DEFAULT_THEME);
attributes.setThemeSilent(customTheme, getResources());
attributes.setFontFamily(a.getString(R.styleable.fl_FlatEditText_fl_fontFamily));
attributes.setFontWeight(a.getString(R.styleable.fl_FlatEditText_fl_fontWeight));
attributes.setFontExtension(a.getString(R.styleable.fl_FlatEditText_fl_fontExtension));
attributes.setTextAppearance(a.getInt(R.styleable.fl_FlatEditText_fl_textAppearance, Attributes.DEFAULT_TEXT_APPEARANCE));
attributes.setRadius(a.getDimensionPixelSize(R.styleable.fl_FlatEditText_fl_cornerRadius, Attributes.DEFAULT_RADIUS_PX));
attributes.setBorderWidth(a.getDimensionPixelSize(R.styleable.fl_FlatEditText_fl_borderWidth, Attributes.DEFAULT_BORDER_WIDTH_PX));
// getting view specific attributes
style = a.getInt(R.styleable.fl_FlatEditText_fl_fieldStyle, 0);
a.recycle();
}
GradientDrawable backgroundDrawable = new GradientDrawable();
backgroundDrawable.setCornerRadius(attributes.getRadius());
if (style == 0) { // flat
if (!hasOwnTextColor) setTextColor(attributes.getColor(3));
backgroundDrawable.setColor(attributes.getColor(2));
backgroundDrawable.setStroke(0, attributes.getColor(2));
} else if (style == 1) { // box
if (!hasOwnTextColor) setTextColor(attributes.getColor(2));
backgroundDrawable.setColor(Color.WHITE);
backgroundDrawable.setStroke(attributes.getBorderWidth(), attributes.getColor(2));
} else if (style == 2) { // transparent
if (!hasOwnTextColor) setTextColor(attributes.getColor(1));
backgroundDrawable.setColor(Color.TRANSPARENT);
backgroundDrawable.setStroke(attributes.getBorderWidth(), attributes.getColor(2));
}
setBackgroundDrawable(backgroundDrawable);
if (!hasOwnHintColor) setHintTextColor(attributes.getColor(3));
if (attributes.getTextAppearance() == 1) setTextColor(attributes.getColor(0));
else if (attributes.getTextAppearance() == 2) setTextColor(attributes.getColor(3));
// check for IDE preview render
if(!this.isInEditMode()) {
Typeface typeface = FlatUI.getFont(getContext(), attributes);
if (typeface != null) setTypeface(typeface);
}
}
示例3: init
import com.cengalabs.flatui.FlatUI; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
if (attributes == null)
attributes = new Attributes(this, getResources());
if (attrs != null) {
// getting android default tags for textColor and textColorHint
hasOwnTextColor = attrs.getAttributeValue(FlatUI.androidStyleNameSpace, "textColor") != null;
hasOwnHintColor = attrs.getAttributeValue(FlatUI.androidStyleNameSpace, "textColorHint") != null;
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.fl_FlatAutoCompleteTextView);
// getting common attributes
int customTheme = a.getResourceId(R.styleable.fl_FlatAutoCompleteTextView_fl_theme, Attributes.DEFAULT_THEME);
attributes.setThemeSilent(customTheme, getResources());
attributes.setFontFamily(a.getString(R.styleable.fl_FlatAutoCompleteTextView_fl_fontFamily));
attributes.setFontWeight(a.getString(R.styleable.fl_FlatAutoCompleteTextView_fl_fontWeight));
attributes.setFontExtension(a.getString(R.styleable.fl_FlatAutoCompleteTextView_fl_fontExtension));
attributes.setTextAppearance(a.getInt(R.styleable.fl_FlatAutoCompleteTextView_fl_textAppearance, Attributes.DEFAULT_TEXT_APPEARANCE));
attributes.setRadius(a.getDimensionPixelSize(R.styleable.fl_FlatAutoCompleteTextView_fl_cornerRadius, Attributes.DEFAULT_RADIUS_PX));
attributes.setBorderWidth(a.getDimensionPixelSize(R.styleable.fl_FlatAutoCompleteTextView_fl_borderWidth, Attributes.DEFAULT_BORDER_WIDTH_PX));
// getting view specific attributes
style = a.getInt(R.styleable.fl_FlatAutoCompleteTextView_fl_autoFieldStyle, 0);
a.recycle();
}
GradientDrawable backgroundDrawable = new GradientDrawable();
backgroundDrawable.setCornerRadius(attributes.getRadius());
if (style == 0) { // flat
if (!hasOwnTextColor) setTextColor(attributes.getColor(3));
backgroundDrawable.setColor(attributes.getColor(2));
backgroundDrawable.setStroke(0, attributes.getColor(2));
} else if (style == 1) { // box
if (!hasOwnTextColor) setTextColor(attributes.getColor(2));
backgroundDrawable.setColor(Color.WHITE);
backgroundDrawable.setStroke(attributes.getBorderWidth(), attributes.getColor(2));
} else if (style == 2) { // transparent
if (!hasOwnTextColor) setTextColor(attributes.getColor(1));
backgroundDrawable.setColor(Color.TRANSPARENT);
backgroundDrawable.setStroke(attributes.getBorderWidth(), attributes.getColor(2));
}
setBackgroundDrawable(backgroundDrawable);
if (!hasOwnHintColor) setHintTextColor(attributes.getColor(3));
if (attributes.getTextAppearance() == 1) setTextColor(attributes.getColor(0));
else if (attributes.getTextAppearance() == 2) setTextColor(attributes.getColor(3));
// check for IDE preview render
if(!this.isInEditMode()) {
Typeface typeface = FlatUI.getFont(getContext(), attributes);
if (typeface != null) setTypeface(typeface);
}
}