本文整理汇总了Java中android.support.v7.widget.AppCompatTextView.setTypeface方法的典型用法代码示例。如果您正苦于以下问题:Java AppCompatTextView.setTypeface方法的具体用法?Java AppCompatTextView.setTypeface怎么用?Java AppCompatTextView.setTypeface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.AppCompatTextView
的用法示例。
在下文中一共展示了AppCompatTextView.setTypeface方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTabLayout
import android.support.v7.widget.AppCompatTextView; //导入方法依赖的package包/类
@NonNull
private TabLayout setTabLayout(View view) {
TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab_layout_rewards);
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.available_rewards_tab)));
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.exchanged_rewards_tab)));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
Typeface typeface = Typeface.createFromAsset(getContext().getAssets(),
"fonts/Nunito-Regular.ttf");
ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0);
for (int i = 0; i < 2; i++) {
AppCompatTextView appCompatTextView = (AppCompatTextView) ((ViewGroup) viewGroup
.getChildAt(i)).getChildAt(1);
appCompatTextView.setTypeface(typeface, Typeface.NORMAL);
}
return tabLayout;
}
示例2: init
import android.support.v7.widget.AppCompatTextView; //导入方法依赖的package包/类
private void init(Context context) {
setOrientation(HORIZONTAL);
//Title
mTitleTextView = new AppCompatTextView(context);
mTitleTextView.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
mTitleTextView.setTypeface(Typeface.DEFAULT_BOLD);
//Value
mValueTextView = new AppCompatTextView(context);
mValueTextView.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
addView(mTitleTextView);
addView(mValueTextView);
}
示例3: onCreateView
import android.support.v7.widget.AppCompatTextView; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.permission_rationale, container, false);
AppCompatTextView rationaleView = (AppCompatTextView) rootView.findViewById(R.id.permission_text);
rationaleView.setText(getArguments().getString(TEXT_KEY));
rationaleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getArguments().getFloat(TEXT_SIZE));
rationaleView.setTextColor(getArguments().getInt(TEXT_COLOR));
rationaleView.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "fonts/" + getArguments().getString(TEXT_FONT)));
return rootView;
}