当前位置: 首页>>代码示例>>Java>>正文


Java TextView.setPadding方法代码示例

本文整理汇总了Java中android.widget.TextView.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setPadding方法的具体用法?Java TextView.setPadding怎么用?Java TextView.setPadding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.setPadding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!WizardSPUtils.shouldShowWizard(this)) {
        startActivity (new Intent(this,
                MainActivity.class));
        finish();
        return;
    }
    SetupWizardLayout layout = new SetupWizardLayout(this);
    layout.getNavigationBar()
            .setNavigationBarListener(this);
    TextView textView = new TextView(this);
    textView.setText(Html.fromHtml(getString(R.string.wizard_descr)));
    int padding = (int) getResources().getDimension(R.dimen.suw_glif_margin_sides);
    textView.setPadding(padding, padding, padding, padding);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    layout.addView(textView);
    layout.setHeaderText(R.string.app_name);
    setContentView(layout);
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:22,代码来源:WelcomeActivity.java

示例2: createDefaultTabView

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
            outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}
 
开发者ID:VitorPoncell,项目名称:poturnoChat,代码行数:24,代码来源:SlidingTabLayout.java

示例3: TopHolder

import android.widget.TextView; //导入方法依赖的package包/类
TopHolder(View view) {
    super(view);

    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.width = getScreenWidth(context) / 5;

    item = new TextView(view.getContext());
    item.setLayoutParams(params);
    item.setMaxLines(1);
    item.setEllipsize(TextUtils.TruncateAt.END);
    item.setGravity(Gravity.CENTER);
    item.setTextColor(ContextCompat.getColor(view.getContext(), R.color.gray_dark));
    item.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension(R.dimen.app_normal_margin));
    item.setCompoundDrawablePadding(topPadding);
    item.setPadding(0, padding, 0, padding);

    TypedValue typedValue = new TypedValue();
    view.getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);
    item.setBackgroundResource(typedValue.resourceId);

    ((LinearLayout) view).addView(item);
}
 
开发者ID:yangchong211,项目名称:YCDialog,代码行数:23,代码来源:DialogAdapter.java

示例4: getView

import android.widget.TextView; //导入方法依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) 
{
	// get the view that would normally be returned
	TextView tv = (TextView) super.getView(position, convertView, parent);
	
	// update the text accordingly
	File f = new File(tv.getText().toString());
	if (f.isDirectory())
		tv.setText(f.getName() + "/");
	else
		tv.setText(f.getName());

	// change some options
	tv.setPadding(10,3,3,3);
	tv.setTextSize(18.0f);
	
	return (View) tv;	// return the view
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:19,代码来源:FileAutoCompleteArrayAdapter.java

示例5: createDefaultTabView

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
            outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:SlidingTabLayout.java

示例6: showProgressDialog

import android.widget.TextView; //导入方法依赖的package包/类
private void showProgressDialog() {
    if (mProgressDialog == null) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        LinearLayout dialogView = new LinearLayout(this);
        dialogView.setOrientation(LinearLayout.VERTICAL);
        ProgressBar progressBar = new ProgressBar(this);
        dialogView.addView(progressBar);
        TextView tvMessage = new TextView(this);
        tvMessage.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
        tvMessage.setTextColor(Color.WHITE);
        tvMessage.setText(R.string.saving);
        tvMessage.setGravity(Gravity.CENTER);
        tvMessage.setPadding(0, Util.dip2px(5), 0, Util.dip2px(5));
        tvMessage.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        dialogView.addView(tvMessage);
        builder.setView(dialogView);
        mProgressDialog = builder.create();
        mProgressDialog.setCancelable(false);
    }
    mProgressDialog.show();
    WindowManager.LayoutParams params = mProgressDialog.getWindow().getAttributes();
    params.width = (int) (Util.getScreenWidth()*0.4);
    mProgressDialog.getWindow().setAttributes(params);
    mProgressDialog.getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.BgToolBar));
}
 
开发者ID:liuke2016,项目名称:filepicker,代码行数:26,代码来源:ImageEditActivity.java

示例7: createTag

import android.widget.TextView; //导入方法依赖的package包/类
private void createTag(String s, @ColorInt int tintColor) {
    TextView textView = new TextView(getContext());
    LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.rightMargin = dp2px(4);
    textView.setLayoutParams(lp);
    textView.setTextSize(9);
    Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.shape_round_stroke_bg_tag);
    DrawableCompat.setTint(drawable, tintColor);
    if (Build.VERSION.SDK_INT > 15)
        textView.setBackground(drawable);
    else
        textView.setBackgroundDrawable(drawable);
    textView.setPadding(dp2px(2), 0, dp2px(2), 0);
    textView.setText(s);

    addView(textView);
}
 
开发者ID:woxingxiao,项目名称:GracefulMovies,代码行数:18,代码来源:TagGroup.java

示例8: PRTHeader

import android.widget.TextView; //导入方法依赖的package包/类
public PRTHeader(Context context) {
	super(context);
	setOrientation(VERTICAL);

	LinearLayout llInner = new LinearLayout(context);
	LinearLayout.LayoutParams lpInner = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpInner.gravity = Gravity.CENTER_HORIZONTAL;
	addView(llInner, lpInner);

	ivArrow = new RotateImageView(context);
	int resId = getBitmapRes(context, "ssdk_oks_ptr_ptr");
	if (resId > 0) {
		ivArrow.setImageResource(resId);
	}
	int dp_32 = dipToPx(context, 32);
	LayoutParams lpIv = new LayoutParams(dp_32, dp_32);
	lpIv.gravity = Gravity.CENTER_VERTICAL;
	llInner.addView(ivArrow, lpIv);

	pbRefreshing = new ProgressBar(context);
	llInner.addView(pbRefreshing, lpIv);
	pbRefreshing.setVisibility(View.GONE);

	tvHeader = new TextView(getContext());
	tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	tvHeader.setGravity(Gravity.CENTER);
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
	tvHeader.setPadding(dp_10, dp_10, dp_10, dp_10);
	tvHeader.setTextColor(0xff000000);
	LayoutParams lpTv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_VERTICAL;
	llInner.addView(tvHeader, lpTv);
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:36,代码来源:FollowList.java

示例9: addMoreInfoLink

import android.widget.TextView; //导入方法依赖的package包/类
@CalledByNative
private void addMoreInfoLink(String linkText) {
    mMoreInfoLink = new TextView(mContext);
    mLinkUrl = HELP_URL;
    mMoreInfoLink.setText(linkText);
    mMoreInfoLink.setTextColor(ApiCompatibilityUtils.getColor(
            mContext.getResources(), R.color.website_settings_popup_text_link));
    mMoreInfoLink.setTextSize(DESCRIPTION_TEXT_SIZE_SP);
    mMoreInfoLink.setPadding(0, mPaddingThin, 0, 0);
    mMoreInfoLink.setOnClickListener(this);
    mDescriptionLayout.addView(mMoreInfoLink);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:ConnectionInfoPopup.java

示例10: onCreateViewHolder

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    TextView textView = new AppCompatTextView(MainActivity.this); // don't do this at home
    RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    int _16dpInPx = ((Float) ScreenUtils.dpToPx(16)).intValue();
    textView.setPadding(_16dpInPx, _16dpInPx, _16dpInPx, _16dpInPx);
    textView.setLayoutParams(layoutParams);
    return new ViewHolder(textView);
}
 
开发者ID:Zhuinden,项目名称:realm-helpers,代码行数:12,代码来源:MainActivity.java

示例11: init

import android.widget.TextView; //导入方法依赖的package包/类
private void init() {
    int l = cities.length;
    this.setCanceledOnTouchOutside(true);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    //  LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ScreenUtil.getInstance().dip2px(1));
    //layoutParams.leftMargin=dp2px(12);
    //layoutParams.rightMargin=dp2px(12);
    for (int i = 0; i < l; i++) {
        TextView textView = new TextView(context);
        textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
        textView.setBackgroundResource(R.drawable.selector_view_bg);
        textView.setTextSize(17);
        textView.setTextColor(context.getResources().getColor(R.color.new_text_color_second));
        textView.setText(cities[i]);
        textView.setTag(i);
        textView.setOnClickListener(this);
        textView.setPadding(dp2px(24), dp2px(8), dp2px(24), dp2px(8));
        listBox.addView(textView, layoutParams);

        //            View view = new View(context);
        //            view.setBackgroundColor(context.getResources().getColor(R.color.new_line_border));
        //            listBox.addView(view, params);
    }
    //取消按钮点击监听
    TextView cancle = (TextView) findViewById(R.id.tv_cancel);
    cancle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SelectCityDialog.this.cancel();
        }
    });
    if (!TextUtils.isEmpty(title))
        ((TextView) findViewById(R.id.dsc_title)).setText(title);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:35,代码来源:SelectCityDialog.java

示例12: PRTHeader

import android.widget.TextView; //导入方法依赖的package包/类
public PRTHeader(Context context) {
	super(context);
	int[] size = ResHelper.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 = ResHelper.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 = ResHelper.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);
}
 
开发者ID:ittianyu,项目名称:POCenter,代码行数:41,代码来源:PRTHeader.java

示例13: 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);
}
 
开发者ID:android-jian,项目名称:topnews,代码行数:41,代码来源:EditPagePort.java

示例14: init

import android.widget.TextView; //导入方法依赖的package包/类
private void init(Context context) {
	tvEmpty = new TextView(context);
	int tvEmptySize = getResources().getDimensionPixelSize(ResHelper.getResId(context, "dimen", "bbs_empty_view_txt_size"));
	tvEmpty.setTextSize(TypedValue.COMPLEX_UNIT_PX, tvEmptySize);
	int padding = ResHelper.dipToPx(context, 10);
	tvEmpty.setPadding(padding, padding, padding, padding);
	int tvEmptyColor = getResources().getColor(ResHelper.getColorRes(context, "bbs_empty_view_txt_color"));
	tvEmpty.setTextColor(tvEmptyColor);
	tvEmpty.setId(ResHelper.getIdRes(context, "tvEmpty"));

	ivEmpty = new ImageView(context);
	ivEmpty.setScaleType(ImageView.ScaleType.CENTER);

	LayoutParams rlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	rlp.addRule(CENTER_IN_PARENT, TRUE);
	addView(tvEmpty, rlp);

	rlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	rlp.addRule(CENTER_HORIZONTAL, TRUE);
	rlp.addRule(ABOVE, tvEmpty.getId());
	addView(ivEmpty, rlp);

	OnClickListener ocl = new OnClickListener() {
		public void onClick(View view) {
			tvEmpty.setClickable(false);
			ivEmpty.setClickable(false);
			if (onRefreshClickListener != null) {
				onRefreshClickListener.onClick(view);
			}
		}
	};
	tvEmpty.setClickable(false);
	ivEmpty.setClickable(false);
	tvEmpty.setOnClickListener(ocl);
	ivEmpty.setOnClickListener(ocl);
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:37,代码来源:EmptyView.java

示例15: setDailyItem

import android.widget.TextView; //导入方法依赖的package包/类
private void setDailyItem(List<Gank> list, String type, ItemViewHolder holder) {
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        TextView tv = new TextView(context);
        tv.setTextSize(25);
        tv.setTextColor(context.getResources().getColor(R.color.textPrimary));
        tv.setPadding(8, 8, 8, 8);
        LinearLayout.LayoutParams tvp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        tvp.setMargins(10, 0, 5, 10);
        tv.setLayoutParams(tvp);
        tv.setTypeface(Typeface.DEFAULT_BOLD);
        tv.setText(type);
        linearLayout.addView(tv);

        for (int i = 0; i < list.size(); i++) {
            TextView items = new TextView(context);
            items.setPadding(15, 5, 5, 10);
            items.setTextSize(14);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT);
            lp.setMargins(10, 0, 5, 10);
            items.setLayoutParams(lp);
            items.setTextColor(context.getResources().getColor(R.color.textSecondary));
            String who = "";
            if (list.get(i).getWho()!= null){
                who =  list.get(i).getWho();
            }else{
                who = "匿名";
            }
            items.setText("*\b" + list.get(i).getDesc() + "\b\b\b" + "-----via." +who);
            linearLayout.addView(items);
            items.setOnClickListener(new MyClickListener(list,i));
        }
        holder.card.addView(linearLayout);
}
 
开发者ID:HStanN,项目名称:TakeRest,代码行数:37,代码来源:DailyAdapter.java


注:本文中的android.widget.TextView.setPadding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。