本文整理匯總了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;
}