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


Java TextView.setLineSpacing方法代码示例

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


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

示例1: init

import android.widget.TextView; //导入方法依赖的package包/类
private void init() {
    setOrientation(VERTICAL); //设置垂直布局
    setGravity(Gravity.CENTER); //中间对齐
    //初始化textView并添加
    contentView = new TextView(getContext());
    //添加行距
    contentView.setLineSpacing(1f, 1.3f);
    addView(contentView, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    //初始化ImageView并添加
    expandView = new ImageView(getContext());
    int padding = UIUtils.dp2px(getContext(), 5);
    expandView.setPadding(padding, padding, padding, padding);
    expandView.setImageResource(R.drawable.ic_arrow_down);
    LayoutParams llp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    addView(expandView, llp);
}
 
开发者ID:coderwjq,项目名称:ZhaZhaShop,代码行数:17,代码来源:ExpandTextView.java

示例2: create

import android.widget.TextView; //导入方法依赖的package包/类
static RelativeLayout create(Context context) {
	SizeHelper.prepare(context);

	RelativeLayout root = new RelativeLayout(context);
	ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
			ViewGroup.LayoutParams.MATCH_PARENT);
	root.setLayoutParams(params);

	TextView title = new TextView(context);
	title.setId(ResHelper.getIdRes(context, "tv_title"));
	RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
			SizeHelper.fromPxWidth(40));
	titleParams.topMargin = SizeHelper.fromPxWidth(-20);
	title.setLayoutParams(titleParams);
	title.setPadding(SizeHelper.fromPxWidth(20), 0, 0, 0);
	title.setLineSpacing(SizeHelper.fromPxWidth(8), 1);
	int resid = ResHelper.getStringRes(context, "smssdk_regist");
	title.setText(resid);
	title.setTextColor(0xff999999);
	title.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(26));
	title.setGravity(Gravity.CENTER_VERTICAL);
	title.setBackgroundColor(0xffeae8ee);
	root.addView(title);

	return root;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:ListviewTitleLayout.java

示例3: setupTextView

import android.widget.TextView; //导入方法依赖的package包/类
private void setupTextView(final TextView textView, final int leading, final int step) {
    // This is to make the behavior more deterministic: remove extra top/bottom padding
    textView.setIncludeFontPadding(false);

    // Get font metrics and calculate required inter-line extra
    Paint.FontMetricsInt metrics = textView.getPaint().getFontMetricsInt();
    final int extra = leading - metrics.descent + metrics.ascent;
    textView.setLineSpacing(extra, 1);

    // Determine minimum required top extra so that the view lands on the grid
    final int alignTopExtra = (step + metrics.ascent % step) % step;
    // Determine minimum required bottom extra so that view bounds are aligned with the grid
    final int alignBottomExtra = (step - metrics.descent % step) % step;

    textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop() + alignTopExtra,
            textView.getPaddingRight(), textView.getPaddingBottom() + alignBottomExtra);
}
 
开发者ID:lurbas,项目名称:ListItemView,代码行数:18,代码来源:ListItemView.java

示例4: initNormalPopupIfNeed

import android.widget.TextView; //导入方法依赖的package包/类
private void initNormalPopupIfNeed() {
    if (mNormalPopup == null) {
        mNormalPopup = new QMUIPopup(getContext(), QMUIPopup.DIRECTION_NONE);
        TextView textView = new TextView(getContext());
        textView.setLayoutParams(mNormalPopup.generateLayoutParam(
                QMUIDisplayHelper.dp2px(getContext(), 250),
                WRAP_CONTENT
        ));
        textView.setLineSpacing(QMUIDisplayHelper.dp2px(getContext(), 4), 1.0f);
        int padding = QMUIDisplayHelper.dp2px(getContext(), 20);
        textView.setPadding(padding, padding, padding, padding);
        textView.setText("Popup 可以设置其位置以及显示和隐藏的动画");
        textView.setTextColor(ContextCompat.getColor(getContext(), R.color.app_color_description));
        mNormalPopup.setContentView(textView);
        mNormalPopup.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mActionButton1.setText(getContext().getResources().getString(R.string.popup_normal_action_button_text_show));
            }
        });
    }
}
 
开发者ID:coopese,项目名称:qmui,代码行数:23,代码来源:QDPopupFragment.java

示例5: onBuildContent

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public View onBuildContent(QMUIDialog dialog, ScrollView parent) {
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    int padding = QMUIDisplayHelper.dp2px(mContext, 20);
    layout.setPadding(padding, padding, padding, padding);
    mEditText = new EditText(mContext);
    QMUIViewHelper.setBackgroundKeepingPadding(mEditText, QMUIResHelper.getAttrDrawable(mContext, R.attr.qmui_list_item_bg_with_border_bottom));
    mEditText.setHint("输入框");
    LinearLayout.LayoutParams editTextLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dpToPx(50));
    editTextLP.bottomMargin = QMUIDisplayHelper.dp2px(getContext(), 15);
    mEditText.setLayoutParams(editTextLP);
    layout.addView(mEditText);
    TextView textView = new TextView(mContext);
    textView.setLineSpacing(QMUIDisplayHelper.dp2px(getContext(), 4), 1.0f);
    textView.setText("观察聚焦输入框后,键盘升起降下时 dialog 的高度自适应变化。\n\n" +
            "QMUI Android 的设计目的是用于辅助快速搭建一个具备基本设计还原效果的 Android 项目," +
            "同时利用自身提供的丰富控件及兼容处理,让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。" +
            "不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。");
    textView.setTextColor(ContextCompat.getColor(getContext(), R.color.app_color_description));
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    layout.addView(textView);
    return layout;
}
 
开发者ID:coopese,项目名称:qmui,代码行数:26,代码来源:QDDialogFragment.java

示例6: setMessage

import android.widget.TextView; //导入方法依赖的package包/类
public void setMessage(Spanned spanned) {
    ScrollView scrollView = new ScrollView(getContext());
    scrollView.setLayoutParams(new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    TextView tvMessage = new TextView(getContext(), null,
            R.style.dialog_pinterest_text);
    tvMessage.setLayoutParams(new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    tvMessage.setPadding(contentPadding, contentPadding, contentPadding,
            contentPadding);
    tvMessage.setLineSpacing(0.0F, 1.3F);
    tvMessage.setText(spanned);
    tvMessage.setTextColor(getContext().getResources().getColor(
            R.color.black));

    ScrollView.LayoutParams lp = new ScrollView.LayoutParams(
            ScrollView.LayoutParams.MATCH_PARENT,
            ScrollView.LayoutParams.WRAP_CONTENT);
    scrollView.addView(tvMessage, lp);
    setContent(scrollView, 0);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:24,代码来源:CommonDialog.java

示例7: onCustomiseDialog

import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected @NonNull DynamicDialog onCustomiseDialog(@NonNull DynamicDialog alertDialog,
                                                   @Nullable Bundle savedInstanceState) {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_about,
            new LinearLayout(getContext()), false);
    TextView message = view.findViewById(R.id.dialog_about_text);

    message.setText(Html.fromHtml(getString(R.string.about_content)
            .replace("\n", "<br/>")));
    message.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE);
    message.setLineSpacing(0f, 1.2f);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setLinkTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));

    alertDialog.setView(view);
    return alertDialog;
}
 
开发者ID:pranavpandey,项目名称:dynamic-toasts,代码行数:18,代码来源:AboutDialogFragment.java

示例8: MessageDialogBuilder

import android.widget.TextView; //导入方法依赖的package包/类
public MessageDialogBuilder(Context context) {
    super(context);
    mTextView = new TextView(mContext);
    mTextView.setTextColor(QMUIResHelper.getAttrColor(mContext, R.attr.qmui_config_color_gray_4));
    mTextView.setLineSpacing(QMUIDisplayHelper.dpToPx(2), 1.0f);
    mTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_content_message_text_size));
}
 
开发者ID:coopese,项目名称:qmui,代码行数:8,代码来源:QMUIDialog.java

示例9: CheckBoxMessageDialogBuilder

import android.widget.TextView; //导入方法依赖的package包/类
public CheckBoxMessageDialogBuilder(Context context) {
    super(context);
    mCheckMarkDrawable = QMUIResHelper.getAttrDrawable(context, R.attr.qmui_s_checkbox);

    mTextView = new TextView(mContext);
    mTextView.setTextColor(QMUIResHelper.getAttrColor(mContext, R.attr.qmui_config_color_gray_4));
    mTextView.setLineSpacing(QMUIDisplayHelper.dpToPx(2), 1.0f);
    mTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_content_message_text_size));
}
 
开发者ID:coopese,项目名称:qmui,代码行数:10,代码来源:QMUIDialog.java

示例10: 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);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:16,代码来源:QMUIDialogBlockBuilder.java

示例11: showAboutDialog

import android.widget.TextView; //导入方法依赖的package包/类
public void showAboutDialog()
{
	Dialog dialog = new Dialog(this);
	/*dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
			WindowManager.LayoutParams.FLAG_BLUR_BEHIND);*/
	
	LinearLayout mDialogLayout = new LinearLayout(this);

	TextView mTextView = new TextView(this);
	mTextView.setPadding(20, 0, 20, 20);
	mTextView.setLineSpacing(8, 1);
	mTextView.setText(Html.fromHtml(
			"<p>" +
			"Author: Rémy Böhler<br />" +
			"E-Mail: [email protected]" +
			"</p>" +
			
			"Version: 0.2<br />" +
			"License: GPLv3<br />" + 
			"Source: github.com/rrelmy/BatteryLevel"
	));
	// TODO better way for that?
	// link mail
	Pattern patternMail = Pattern.compile("[email protected]");
	Linkify.addLinks(mTextView, patternMail, "mailto://");
	// link source link
	Pattern patternLink = Pattern.compile("github.com/rrelmy/BatteryLevel");
	Linkify.addLinks(mTextView, patternLink, "https://");
	
	mDialogLayout.addView(mTextView);
	
	dialog.setContentView(mDialogLayout);
	dialog.setTitle("About");
	dialog.show();
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:36,代码来源:Main.java

示例12: create

import android.widget.TextView; //导入方法依赖的package包/类
/**验证返回对话框布局*/
public static LinearLayout create(Context context) {
	SizeHelper.prepare(context);

	LinearLayout root = new LinearLayout(context);
	ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
	root.setLayoutParams(params);
	root.setOrientation(LinearLayout.VERTICAL);

	TextView dialogHint = new TextView(context);
	dialogHint.setId(ResHelper.getIdRes(context, "tv_dialog_hint"));
	LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	hintParams.topMargin = SizeHelper.fromPxWidth(32);
	hintParams.bottomMargin = SizeHelper.fromPxWidth(32);
	dialogHint.setLayoutParams(hintParams);
	dialogHint.setPadding(SizeHelper.fromPxWidth(18), 0, SizeHelper.fromPxWidth(18), 0);
	dialogHint.setLineSpacing(SizeHelper.fromPxWidth(8), 1);
	int resid = ResHelper.getStringRes(context, "smssdk_make_sure_mobile_detail");
	dialogHint.setText(resid);
	dialogHint.setTextColor(0xffffffff);
	dialogHint.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(26));
	dialogHint.setGravity(Gravity.CENTER);
	root.addView(dialogHint);

	View line = new View(context);
	LinearLayout.LayoutParams lineParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
			SizeHelper.fromPxWidth(1));
	line.setLayoutParams(lineParams);
	line.setBackgroundColor(0xff737373);
	root.addView(line);

	LinearLayout wrapper = new LinearLayout(context);
	LinearLayout.LayoutParams wrapperParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	wrapper.setLayoutParams(wrapperParams);


	Button ok = new Button(context);
	ok.setId(ResHelper.getIdRes(context, "btn_dialog_ok"));
	LinearLayout.LayoutParams okParams = new LinearLayout.LayoutParams(0,SizeHelper.fromPxWidth(78),1);
	okParams.leftMargin = SizeHelper.fromPxWidth(3);
	ok.setLayoutParams(okParams);
	resid = ResHelper.getBitmapRes(context, "smssdk_dialog_btn_back");
	ok.setBackgroundResource(resid);
	int padding = SizeHelper.fromPxWidth(8);
	ok.setPadding(padding, padding, padding, padding);
	resid = ResHelper.getStringRes(context, "smssdk_ok");
	ok.setText(resid);
	ok.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
	ok.setTextColor(0xffffffff);
	wrapper.addView(ok);

	View line2 = new View(context);
	LinearLayout.LayoutParams line2Params = new LinearLayout.LayoutParams(SizeHelper.fromPxWidth(1),
			LinearLayout.LayoutParams.MATCH_PARENT);
	line2.setLayoutParams(line2Params);
	line2.setBackgroundColor(0xff737373);
	wrapper.addView(line2);

	Button cancel = new Button(context);
	cancel.setId(ResHelper.getIdRes(context, "btn_dialog_cancel"));
	LinearLayout.LayoutParams cancelParams = new LinearLayout.LayoutParams(0,SizeHelper.fromPxWidth(78),1);
	cancelParams.rightMargin = SizeHelper.fromPxWidth(3);
	cancel.setLayoutParams(cancelParams);
	resid = ResHelper.getBitmapRes(context, "smssdk_dialog_btn_back");
	cancel.setBackgroundResource(resid);
	cancel.setPadding(padding, padding, padding, padding);
	resid = ResHelper.getStringRes(context, "smssdk_cancel");
	cancel.setText(resid);
	cancel.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
	cancel.setTextColor(0xffffffff);
	wrapper.addView(cancel);

	root.addView(wrapper);
	return root;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:78,代码来源:BackVerifyDialogLayout.java

示例13: LoginActivityResetWaitView

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

    setOrientation(VERTICAL);

    confirmTextView = new TextView(context);
    confirmTextView.setTextColor(0xff757575);
    confirmTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    confirmTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    confirmTextView.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
    addView(confirmTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));

    TextView resetAccountText = new TextView(context);
    resetAccountText.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    resetAccountText.setTextColor(0xff757575);
    resetAccountText.setText(LocaleController.getString("ResetAccountStatus", R.string.ResetAccountStatus));
    resetAccountText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    resetAccountText.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
    addView(resetAccountText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 0, 24, 0, 0));

    resetAccountTime = new TextView(context);
    resetAccountTime.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    resetAccountTime.setTextColor(0xff757575);
    resetAccountTime.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    resetAccountTime.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
    addView(resetAccountTime, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 0, 2, 0, 0));

    resetAccountButton = new TextView(context);
    resetAccountButton.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    resetAccountButton.setText(LocaleController.getString("ResetAccountButton", R.string.ResetAccountButton));
    resetAccountButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    resetAccountButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    resetAccountButton.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
    resetAccountButton.setPadding(0, AndroidUtilities.dp(14), 0, 0);
    addView(resetAccountButton, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 0, 7, 0, 0));
    resetAccountButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (Math.abs(ConnectionsManager.getInstance().getCurrentTime() - startTime) < waitTime) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setMessage(LocaleController.getString("ResetMyAccountWarningText", R.string.ResetMyAccountWarningText));
            builder.setTitle(LocaleController.getString("ResetMyAccountWarning", R.string.ResetMyAccountWarning));
            builder.setPositiveButton(LocaleController.getString("ResetMyAccountWarningReset", R.string.ResetMyAccountWarningReset), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    needShowProgress();
                    TLRPC.TL_account_deleteAccount req = new TLRPC.TL_account_deleteAccount();
                    req.reason = "Forgot password";
                    ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                        @Override
                        public void run(TLObject response, final TLRPC.TL_error error) {
                            AndroidUtilities.runOnUIThread(new Runnable() {
                                @Override
                                public void run() {
                                    needHideProgress();
                                    if (error == null) {
                                        Bundle params = new Bundle();
                                        params.putString("phoneFormated", requestPhone);
                                        params.putString("phoneHash", phoneHash);
                                        params.putString("code", phoneCode);
                                        setPage(5, true, params, false);
                                    } else {
                                        if (error.text.equals("2FA_RECENT_CONFIRM")) {
                                            needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("ResetAccountCancelledAlert", R.string.ResetAccountCancelledAlert));
                                        } else {
                                            needShowAlert(LocaleController.getString("AppName", R.string.AppName), error.text);
                                        }
                                    }
                                }
                            });
                        }
                    }, ConnectionsManager.RequestFlagWithoutLogin | ConnectionsManager.RequestFlagFailOnServerErrors);
                }
            });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
        }
    });
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:82,代码来源:LoginActivity.java

示例14: setSheetItems

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 生成条目
 */
private void setSheetItems() {
    if (listSheetItem == null || listSheetItem.size() <= 0) {
        return;
    }
    lLayoutItem.setGravity(STYLE == STYLE_WEI_XIN ? Gravity.LEFT | Gravity.CENTER_VERTICAL : Gravity.CENTER);
    lLayoutItem.removeAllViews();
    // 循环添加条目
    for (int i = 0; i <= listSheetItem.size() - 1; i++) {
        final int item = i;
        SheetItem sheetItem = listSheetItem.get(i);
        final OnSheetItemListener listener = sheetItem.itemClickListener;
        View view = new View(context);

        TextView textView = new TextView(context);
        textView.setText(sheetItem.name);
        textView.setTextSize(unitItems, textSizeItems);
        textView.setGravity(STYLE == STYLE_WEI_XIN ? Gravity.LEFT | Gravity.CENTER_VERTICAL : Gravity.CENTER);
        textView.setPadding(dip2px(mPaddingLeft), dip2px(mPaddingTop), dip2px(mPaddingLeft), dip2px(mPaddingTop));
        vLineTitle.setVisibility(showTitle && STYLE == STYLE_NORMAL ? View.VISIBLE : View.GONE);
        // 背景图片
        if (STYLE == STYLE_IOS) {
            if (listSheetItem.size() == 1) {
                if (showTitle) {
                    textView.setBackgroundResource(R.drawable.action_sheet_bottom);
                } else {
                    textView.setBackgroundResource(R.drawable.action_sheet_single);
                }
            } else {
                if (showTitle) {
                    if (i >= 0 && i < listSheetItem.size() - 1) {
                        textView.setBackgroundResource(R.drawable.action_sheet_middle);
                    } else {
                        textView.setBackgroundResource(R.drawable.action_sheet_bottom);
                    }
                } else {
                    if (i == 0) {
                        textView.setBackgroundResource(R.drawable.action_sheet_top);
                    } else if (i < listSheetItem.size() - 1) {
                        textView.setBackgroundResource(R.drawable.action_sheet_middle);
                    } else {
                        textView.setBackgroundResource(R.drawable.action_sheet_bottom);
                    }
                }
            }
        } else {
            textView.setBackgroundResource(R.drawable.action_sheet_edge);
            tvCancel.setBackgroundResource(R.drawable.action_sheet_edge);
            tvTitle.setBackgroundResource(R.color.colorActionSheetEdge);
            view.setBackgroundResource(R.color.colorActionSheetEdgeLineGray);
        }
        // 字体颜色
        textView.setTextColor(sheetItem.color);
        LinearLayout.LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        // 高度
        textView.setLayoutParams(params);
        textView.setMinimumHeight(getItemHeight());
        tvTitle.setMinimumHeight(STYLE != STYLE_IOS ? getItemHeight() : dip2px(20));
        textView.setLineSpacing(mLineSpacingExtra, mLineSpacingMultiplier);
        // 点击事件
        textView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onClick(item);
                }
                dialog.dismiss();
            }
        });
        lLayoutItem.addView(textView);
        if (STYLE == STYLE_NORMAL) {
            view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, (int) context.getResources().getDimension(R.dimen.dp_line_size)));
            lLayoutItem.addView(view);
        }
    }
}
 
开发者ID:AriesHoo,项目名称:UIWidget,代码行数:79,代码来源:UIActionSheetView.java


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