本文整理汇总了Java中android.support.v4.content.res.ResourcesCompat.getFont方法的典型用法代码示例。如果您正苦于以下问题:Java ResourcesCompat.getFont方法的具体用法?Java ResourcesCompat.getFont怎么用?Java ResourcesCompat.getFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.content.res.ResourcesCompat
的用法示例。
在下文中一共展示了ResourcesCompat.getFont方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setToolbarTypeface
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
@SuppressWarnings("inlineValue")
public static TextView setToolbarTypeface(Toolbar toolbar) {
for (int i = 0; i < toolbar.getChildCount(); i++) {
View view = toolbar.getChildAt(i);
if (view instanceof TextView) {
TextView textView = (TextView) view;
if (textView.getText().equals(toolbar.getTitle())) {
Typeface typeface = ResourcesCompat.getFont(toolbar.getContext(),
R.font.roboto_mono_regular);
textView.setTypeface(typeface);
return textView;
}
}
}
return null;
}
示例2: getDefaultTypeface
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private Typeface getDefaultTypeface(Context context, @FontRes int fontFamily) {
if (fontFamily == 0) {
fontFamily = CalligraphyConfig.get().getFontFamily();
}
if (fontFamily != 0) {
return ResourcesCompat.getFont(context, fontFamily);
}
return null;
}
示例3: setTabFont
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private void setTabFont(int textViewId, @FontRes int font, int position) {
if (font == 0)
return;
Typeface typeface = ResourcesCompat.getFont(getContext(), font);
setTabFont(textViewId, typeface, position);
}
示例4: appBarInit
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private void appBarInit() {
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
collapsingToolbar.setExpandedTitleColor(ContextCompat.getColor(getContext(), android.R.color.white));
collapsingToolbar.setCollapsedTitleTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
Typeface typeface = ResourcesCompat.getFont(getContext(), R.font.titillium);
collapsingToolbar.setCollapsedTitleTypeface(typeface);
collapsingToolbar.setExpandedTitleTypeface(typeface);
}
示例5: appBarInit
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private void appBarInit() {
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
collapsingToolbar.setExpandedTitleColor(ContextCompat.getColor(getContext(), android.R.color.white));
collapsingToolbar.setCollapsedTitleTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
Typeface typeface = ResourcesCompat.getFont(getContext(), R.font.titillium);
collapsingToolbar.setCollapsedTitleTypeface(typeface);
collapsingToolbar.setExpandedTitleTypeface(typeface);
eventsViewPagerAdapter = new EventsViewPagerAdapter(getActivity().getSupportFragmentManager());
viewPager.setAdapter(eventsViewPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
}
示例6: AnimatedPullToRefreshLayout
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public AnimatedPullToRefreshLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
setWillNotDraw(false);
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatedPullToRefreshLayout);
if (a != null) {
String headerText = a.getString(R.styleable.AnimatedPullToRefreshLayout_headerText);
int headerTextSize = a.getDimensionPixelSize(R.styleable.AnimatedPullToRefreshLayout_headerTextSize, (int) getResources().getDimension(R.dimen.headerTextSize));
int headerTextColor = a.getColor(R.styleable.AnimatedPullToRefreshLayout_headerTextColor, getColor(android.R.color.darker_gray));
int headerBackgroundColor = a.getColor(R.styleable.AnimatedPullToRefreshLayout_headerBackgroundColor, getColor(android.R.color.transparent));
HeaderAnimSpeed headerAnimSpeed = HeaderAnimSpeed.fromId(a.getInt(R.styleable.AnimatedPullToRefreshLayout_animationSpeed, HeaderAnimSpeed.FAST.getSpeed()));
HeaderTextAnim headerTextAnim = HeaderTextAnim.fromId(a.getInt(R.styleable.AnimatedPullToRefreshLayout_headerTextAnimation, HeaderTextAnim.ROTATE_CW.getAnimType()));
HeaderLoopAnim headerLoopAnim = HeaderLoopAnim.fromId(a.getInt(R.styleable.AnimatedPullToRefreshLayout_headerLoopAnimation, HeaderLoopAnim.ZOOM.getAnimType()));
int headerTextAnimIteration = a.getInt(R.styleable.AnimatedPullToRefreshLayout_headerTextAnimIteration, HeaderTextAnim.ROTATE_CW.getAnimType());
int headerLoopAnimIteration = a.getInt(R.styleable.AnimatedPullToRefreshLayout_headerLoopAnimIteration, HeaderLoopAnim.ZOOM.getAnimType());
boolean isColorAnimEnabled = a.getBoolean(R.styleable.AnimatedPullToRefreshLayout_headerTextColorAnimationEnabled, true);
Typeface mTitleTypeface = null;
//Font
if (a.hasValue(R.styleable.AnimatedPullToRefreshLayout_headerTextFontFamily)) {
int fontId = a.getResourceId(R.styleable.AnimatedPullToRefreshLayout_headerTextFontFamily, -1);
if (fontId != -1)
mTitleTypeface = ResourcesCompat.getFont(context, fontId);
}
a.recycle();
if (isInEditMode())
return;
// adding header layout : important
headerView = new CharacterAnimatorHeaderView(getContext());
headerView.setHeaderText(headerText);
headerView.setHeaderTextSize(headerTextSize);
headerView.setHeaderTextColor(headerTextColor);
headerView.setHeaderBackgroundColor(headerBackgroundColor);
headerView.setHeaderTextAnim(headerTextAnim);
headerView.setHeaderLoopAnim(headerLoopAnim);
headerView.setHeaderTextAnimIteration(headerTextAnimIteration);
headerView.setHeaderLoopAnimIteration(headerLoopAnimIteration);
headerView.setColorAnimEnable(isColorAnimEnabled);
headerView.setAnimationSpeed(headerAnimSpeed);
headerView.setHeaderTextTypeface(mTitleTypeface);
setHeaderView(headerView);
}
}
示例7: getView
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View vi = convertView;
if (convertView == null)
vi = mInflater.inflate(R.layout.row, null);
TextView tv = (TextView) vi.findViewById(R.id.textView1);
tv1 = (TextView) vi.findViewById(R.id.textView2);
delete_btn = (ImageView) vi.findViewById(R.id.delete_btn);
ImageView image = (ImageView) vi.findViewById(R.id.image_view);
tv.setText(name1.get(position));
String desiredString = tv.getText().toString().substring(0, 2);
Typeface typeface = ResourcesCompat.getFont(ContacsActivity.this, R.font.proxima_nova);
ColorGenerator generator = ColorGenerator.MATERIAL; // or use DEFAULT
int color1 = generator.getRandomColor();
TextDrawable drawable = TextDrawable.builder()
.beginConfig()
.textColor(Color.WHITE)
.useFont(typeface)
.fontSize(50) /* size in px */
.toUpperCase()
.bold()
.endConfig()
.buildRound(desiredString, color1);
image.setImageDrawable(drawable);
tv1.setText(phno1.get(position));
delete_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
name1.remove(position);
phno1.remove(position);
notifyDataSetChanged();
//Toast.makeText(ContacsActivity.this, position+""+name1.size(), Toast.LENGTH_SHORT).show();
editor = mSharedPreference1.edit();
editor.putInt("name_size", name1.size());
editor.putInt("phno_size", phno1.size());
for (int i = 0; i < phno1.size(); i++) {
editor.remove("name_size" + position + 1);
editor.remove("phno_size" + position + 1);
}
editor.commit();
if (phno1.size() != 0) {
done_btn.setVisibility(View.VISIBLE);
no_contact.setVisibility(LinearLayout.GONE);
} else {
done_btn.setVisibility(View.GONE);
no_contact.setVisibility(LinearLayout.VISIBLE);
}
}
});
return vi;
}
示例8: Toaster
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public void Toaster(View v) {
switch (v.getId()) {
case R.id.button1:
StyleableToast.makeText(this, "Uploading image", R.style.allStyles).show();
break;
case R.id.button2:
StyleableToast.makeText(this, "Image saved", Toast.LENGTH_LONG, R.style.style2).show();
break;
case R.id.button3:
Typeface typeface = ResourcesCompat.getFont(this, R.font.toastfont);
new StyleableToast
.Builder(this)
.typeface(typeface)
.text("Turn off flight mode")
.iconResLeft(R.drawable.ic_airplanemode_inactive_black_24dp)
.backgroundColor(Color.parseColor("#865aff"))
.show();
break;
case R.id.button4:
new StyleableToast
.Builder(this)
.text("Updating profile")
.textColor(Color.WHITE)
.backgroundColor(Color.parseColor("#ff5a5f"))
.iconResLeft(R.drawable.ic_autorenew_black_24dp)
.show();
break;
case R.id.button5:
new StyleableToast
.Builder(this)
.text("Milk added to list")
.font(R.font.dosis)
.backgroundColor(Color.parseColor("#74ba82"))
.show();
break;
case R.id.button6:
new StyleableToast
.Builder(this)
.text("Picture saved to gallery")
.textColor(Color.parseColor("#fc2d3e"))
.backgroundColor(Color.parseColor("#dddddd"))
.show();
break;
}
}
示例9: setupView
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private void setupView() {
Typeface typeface = ResourcesCompat.getFont(this, R.font.th_sarabun_new);
tvAnyMessage.setTypeface(typeface);
}