當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。