本文整理匯總了Java中android.widget.TextView.setTextSize方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.setTextSize方法的具體用法?Java TextView.setTextSize怎麽用?Java TextView.setTextSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setTextSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUpReturnOrderView
import android.widget.TextView; //導入方法依賴的package包/類
private void setUpReturnOrderView(ReturnOrderDetailResponse returnOrderDetailResponse) {
TextView tv = new TextView(getActivityContext());
tv.setTextSize(14);
tv.setTextColor(Color.parseColor(getString(R.string.textColorThird)));
tv.setGravity(Gravity.CENTER_VERTICAL);
tv.setTag(returnOrderDetailResponse.getReturnOrder().getReturnOrderID());
if (!TextUtils.isEmpty(returnOrderDetailResponse.getReturnOrder().getName())) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
CommonUtils.dip2px(getActivityContext(), 40));
SpannableString ss = new SpannableString(getString(R.string.tag_return_order_num) + returnOrderDetailResponse.getReturnOrder().getName());
ss.setSpan(new ForegroundColorSpan(Color.parseColor(getString(R.string.color_return_order_num))), 5, 5 + returnOrderDetailResponse.getReturnOrder().getName().length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
tv.setText(ss);
mLlReturn.addView(tv, params);
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//跳轉到退貨單詳情
// Intent intent = new Intent(mContext, ReturnDetailActivity.class);
// intent.putExtra("rid", returnId);
// startActivity(intent);
}
});
}
}
示例2: LeftHolder
import android.widget.TextView; //導入方法依賴的package包/類
LeftHolder(View view) {
super(view);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
view.setLayoutParams(params);
item = new TextView(view.getContext());
item.setLayoutParams(params);
item.setMaxLines(1);
item.setEllipsize(TextUtils.TruncateAt.END);
item.setGravity(Gravity.CENTER_VERTICAL);
item.setTextColor(ContextCompat.getColor(view.getContext(), R.color.gray_black));
item.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension(R.dimen.app_normal_margin));
item.setCompoundDrawablePadding(leftPadding);
item.setPadding(padding, padding, padding, padding);
TypedValue typedValue = new TypedValue();
view.getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);
item.setBackgroundResource(typedValue.resourceId);
((LinearLayout) view).addView(item);
}
示例3: createItem
import android.widget.TextView; //導入方法依賴的package包/類
protected View createItem(final ItemInfo info) {
TextView textView = new TextView(mActivity);
textView.setText(info.mItemText);
textView.setTextColor(SkinHelper.getSkin().getThemeSubColor());
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, SkinHelper.getSkin().getMainTextSize());
textView.setGravity(Gravity.CENTER);
if (info.mClickListener instanceof RClickListener) {
textView.setOnClickListener(info.mClickListener);
} else {
textView.setOnClickListener(new RClickListener(1000) {
@Override
public void onRClick(View view) {
info.mClickListener.onClick(view);
if (info.autoCloseDialog) {
finishDialog();
}
}
});
}
return textView;
}
示例4: updateTabStyles
import android.widget.TextView; //導入方法依賴的package包/類
private void updateTabStyles() {
for (int i = 0; i < mTabCount; i++) {
View tabView = mTabsContainer.getChildAt(i);
tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
// tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
if (mTextAllCaps) {
tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
}
if (mTextBold == TEXT_BOLD_BOTH) {
tv_tab_title.getPaint().setFakeBoldText(true);
} else if (mTextBold == TEXT_BOLD_NONE) {
tv_tab_title.getPaint().setFakeBoldText(false);
}
}
}
示例5: onCreate
import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout root = new LinearLayout(this);
root.setPadding(30, 30, 30, 30);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
root.setLayoutParams(lp);
setContentView(root);
// textView
TextView textView = new TextView(this);
textView.setText("Theme: Dialog");
textView.setGravity(Gravity.CENTER);
textView.setTextSize(30);
LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
textView.setLayoutParams(lp2);
root.addView(textView);
}
示例6: createTextView
import android.widget.TextView; //導入方法依賴的package包/類
private TextView createTextView() {
TextView textView = new TextView(this);
textView.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
textView.setTextColor(Color.CYAN);
textView.setTextSize(30f);
textView.setBackgroundColor(Color.RED);
textView.setText("tips view");
return textView;
}
示例7: onBindView
import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onBindView(Pager.Page page, Holder holder, Element element) {
super.onBindView(page, holder, element);
String text = (String) element.getData();
TextView view = (TextView) holder.getRoot();
view.setText(text);
int size, textColor, bgColor;
switch (element.getElementType()) {
case TYPE_TEXT_SMALL:
size = 16;
textColor = Color.GRAY;
bgColor = Color.TRANSPARENT;
break;
case TYPE_TEXT_MESSAGE:
size = 18;
textColor = Color.WHITE;
bgColor = ContextCompat.getColor(getContext(), R.color.colorAccent);
// textColor = Color.DKGRAY;
// bgColor = Color.WHITE;
break;
case TYPE_TEXT_LARGE:
default:
size = 22;
textColor = Color.BLACK;
bgColor = Color.TRANSPARENT;
break;
}
view.setTextSize(size);
view.setTextColor(textColor);
view.setBackgroundColor(bgColor);
}
示例8: onCreateContent
import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onCreateContent(QMUIDialog dialog, ViewGroup parent) {
TextView contentTv = new TextView(mContext);
contentTv.setTextColor(QMUIResHelper.getAttrColor(mContext, R.attr.qmui_config_color_gray_4));
contentTv.setText(mContent);
contentTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_block_content_text_size));
contentTv.setLineSpacing(QMUIDisplayHelper.dpToPx(2), 1.0f);
contentTv.setPadding(
QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_padding_horizontal),
QMUIResHelper.getAttrDimen(mContext, hasTitle() ? R.attr.qmui_dialog_content_padding_top : R.attr.qmui_dialog_content_padding_top_when_no_title),
QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_padding_horizontal),
QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_content_padding_bottom_when_action_block)
);
parent.addView(contentTv);
}
示例9: addTextView
import android.widget.TextView; //導入方法依賴的package包/類
/**
* 向父容器中添加TextView
*
* @param text TextView顯示文字
* @param color TextView的背景顏色,如:"#FADBCC"
*/
private void addTextView(Context context, String text, int color) {
TextView textView = new TextView(context);
textView.setBackgroundColor(color);
textView.setText(text);
textView.setTextColor(textColor);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
textView.setSingleLine();
textView.setGravity(Gravity.CENTER);
textView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1.0F));
this.addView(textView);
}
示例10: initBottom
import android.widget.TextView; //導入方法依賴的package包/類
private void initBottom(LinearLayout llBottom, float ratio) {
LinearLayout llAt = new LinearLayout(activity);
llAt.setPadding(0, 0, 0, 5);
llAt.setBackgroundColor(0xffffffff);
int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
llBottom.addView(llAt, lp);
tvAt = new TextView(activity);
tvAt.setTextColor(0xff3b3b3b);
tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
tvAt.setGravity(Gravity.BOTTOM);
tvAt.setText("@");
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
tvAt.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
llAt.addView(tvAt, lp);
tvAt.setOnClickListener(this);
if (isShowAtUserLayout(platform.getName())) {
tvAt.setVisibility(View.VISIBLE);
} else {
tvAt.setVisibility(View.INVISIBLE);
}
tvTextCouter = new TextView(activity);
tvTextCouter.setTextColor(0xff3b3b3b);
tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
onTextChanged(etContent.getText(), 0, 0, 0);
tvTextCouter.setPadding(padding, 0, padding, 0);
lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.weight = 1;
llAt.addView(tvTextCouter, lp);
View v = new View(activity);
v.setBackgroundColor(0xffcccccc);
int px1 = ratio > 1 ? ((int) ratio) : 1;
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
llBottom.addView(v, lp);
}
示例11: PRTHeader
import android.widget.TextView; //導入方法依賴的package包/類
public PRTHeader(Context context) {
super(context);
int[] size = R.getScreenSize(context);
float screenWidth = size[0] < size[1] ? size[0] : size[1];
float ratio = screenWidth / DESIGN_SCREEN_WIDTH;
setOrientation(VERTICAL);
LinearLayout llInner = new LinearLayout(context);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_HORIZONTAL;
addView(llInner, lp);
ivArrow = new RotateImageView(context);
int resId = R.getBitmapRes(context, "ssdk_oks_ptr_ptr");
if (resId > 0) {
ivArrow.setImageResource(resId);
}
int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
lp = new LayoutParams(avatarWidth, avatarWidth);
lp.gravity = Gravity.CENTER_VERTICAL;
int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
lp.topMargin = lp.bottomMargin = avataPadding;
llInner.addView(ivArrow, lp);
pbRefreshing = new ProgressBar(context);
resId = R.getBitmapRes(context, "ssdk_oks_classic_progressbar");
Drawable pbdrawable = context.getResources().getDrawable(resId);
pbRefreshing.setIndeterminateDrawable(pbdrawable);
llInner.addView(pbRefreshing, lp);
pbRefreshing.setVisibility(View.GONE);
tvHeader = new TextView(getContext());
tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
tvHeader.setTextColor(0xff09bb07);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_VERTICAL;
llInner.addView(tvHeader, lp);
}
示例12: AlbumView
import android.widget.TextView; //導入方法依賴的package包/類
public AlbumView(Context context) {
super(context);
imageView = new BackupImageView(context);
addView(imageView,
LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
linearLayout.setBackgroundColor(0x7f000000);
addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 28,
Gravity.LEFT | Gravity.BOTTOM));
nameTextView = new TextView(context);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
nameTextView.setTextColor(0xffffffff);
nameTextView.setSingleLine(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setMaxLines(1);
nameTextView.setGravity(Gravity.CENTER_VERTICAL);
linearLayout.addView(nameTextView,
LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 8, 0, 0, 0));
countTextView = new TextView(context);
countTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
countTextView.setTextColor(0xffaaaaaa);
countTextView.setSingleLine(true);
countTextView.setEllipsize(TextUtils.TruncateAt.END);
countTextView.setMaxLines(1);
countTextView.setGravity(Gravity.CENTER_VERTICAL);
linearLayout.addView(countTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
LayoutHelper.MATCH_PARENT, 4, 0, 4, 0));
selector = new View(context);
selector.setBackgroundResource(R.drawable.list_selector);
addView(selector,
LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
示例13: initVideoView
import android.widget.TextView; //導入方法依賴的package包/類
private void initVideoView(Context context) {
mAppContext = context.getApplicationContext();
mSettings = new Settings(mAppContext);
initBackground();
initRenders();
mVideoWidth = 0;
mVideoHeight = 0;
// REMOVED: getHolder().addCallback(mSHCallback);
// REMOVED: getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
setFocusable(true);
setFocusableInTouchMode(true);
requestFocus();
// REMOVED: mPendingSubtitleTracks = new Vector<Pair<InputStream, MediaFormat>>();
mCurrentState = STATE_IDLE;
mTargetState = STATE_IDLE;
subtitleDisplay = new TextView(context);
subtitleDisplay.setTextSize(24);
subtitleDisplay.setGravity(Gravity.CENTER);
LayoutParams layoutParams_txt = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
addView(subtitleDisplay, layoutParams_txt);
}
示例14: setTextSize
import android.widget.TextView; //導入方法依賴的package包/類
private static void setTextSize(Toast toast) {
TextView view = getTextView(toast);
Context context=view.getContext();
int size = context.getResources().getDimensionPixelSize(R.dimen.text_size_middle2);
view.setTextSize(TypedValue.COMPLEX_UNIT_PX,ScreenUtil.getScalePxValue(size));
}
示例15: initTitle
import android.widget.TextView; //導入方法依賴的package包/類
private void initTitle(RelativeLayout rlTitle, float ratio) {
tvCancel = new TextView(activity);
tvCancel.setTextColor(0xff3b3b3b);
tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvCancel.setGravity(Gravity.CENTER);
int resId = R.getStringRes(activity, "ssdk_oks_cancel");
if (resId > 0) {
tvCancel.setText(resId);
}
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
tvCancel.setPadding(padding, 0, padding, 0);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
rlTitle.addView(tvCancel, lp);
tvCancel.setOnClickListener(this);
TextView tvTitle = new TextView(activity);
tvTitle.setTextColor(0xff3b3b3b);
tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
tvTitle.setGravity(Gravity.CENTER);
resId = R.getStringRes(activity, "ssdk_oks_contacts");
if (resId > 0) {
tvTitle.setText(resId);
}
lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.addRule(RelativeLayout.CENTER_IN_PARENT);
rlTitle.addView(tvTitle, lp);
tvConfirm = new TextView(activity);
tvConfirm.setTextColor(0xffff6d11);
tvConfirm.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvConfirm.setGravity(Gravity.CENTER);
resId = R.getStringRes(activity, "ssdk_oks_confirm");
if (resId > 0) {
tvConfirm.setText(resId);
}
tvConfirm.setPadding(padding, 0, padding, 0);
lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rlTitle.addView(tvConfirm, lp);
tvConfirm.setOnClickListener(this);
}