當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.setLayoutParams方法代碼示例

本文整理匯總了Java中android.widget.TextView.setLayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.setLayoutParams方法的具體用法?Java TextView.setLayoutParams怎麽用?Java TextView.setLayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.setLayoutParams方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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:QMUI,項目名稱:QMUI_Android,代碼行數:23,代碼來源:QDPopupFragment.java

示例2: addView

import android.widget.TextView; //導入方法依賴的package包/類
public void addView(TextView childView, String text) {
    if (push_state_ll.getChildCount() > 3) {
        push_state_ll.removeViewAt(0);
    }
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(0, 0, 0, 10);
    childView.setTextColor(Color.RED);
    childView.setText(text);
    childView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13f);
    childView.setBackgroundResource(R.drawable.text_state);
    childView.setLayoutParams(layoutParams);
    childView.setPadding(15, 10, 15, 10);
    childView.setMaxEms(20);
    childView.setMaxLines(3);
    push_state_ll.addView(childView);
}
 
開發者ID:JunGeges,項目名稱:AliZhiBoHao,代碼行數:17,代碼來源:LiveCameraActivity.java

示例3: ToastProgress

import android.widget.TextView; //導入方法依賴的package包/類
public ToastProgress(android.content.Context context) {
	super(context);
	this.ctx=context;
	this.h=new Handler();
	this.h2=new Handler();
	root = new LinearLayout(ctx);
	root.setPadding((int)dp2px(ctx, 20), (int)dp2px(ctx, 10), (int)dp2px(ctx, 20), (int)dp2px(ctx, 10));
	root.setOrientation(LinearLayout.HORIZONTAL);
	prog=new ProgressBar(ctx);
	prog.setLayoutParams(new LinearLayout.LayoutParams((int)dp2px(ctx, 20), (int)dp2px(ctx, 20)));
	root.addView(prog);
	clt=new TextView(ctx);
	clt.setTextSize(14);
	clt.setTextColor(Color.WHITE);
	LinearLayout.LayoutParams tlp=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
	tlp.gravity=Gravity.CENTER_VERTICAL;
	tlp.setMargins((int)dp2px(ctx,10),0,0,0);
	clt.setLayoutParams(tlp);
	root.addView(clt);
	shape = new GradientDrawable();
	shape.setShape(GradientDrawable.RECTANGLE);
}
 
開發者ID:agusibrahim,項目名稱:go-jay,代碼行數:23,代碼來源:ToastProgress.java

示例4: convert

import android.widget.TextView; //導入方法依賴的package包/類
@Override
public void convert(EasyLVHolder holder, int position, String s) {
    holder.setText(R.id.tvMinorItem, s);

    if (current == position) {
        holder.setVisible(R.id.ivMinorChecked, true);
    } else {
        holder.setVisible(R.id.ivMinorChecked, false);
    }

    if (position != 0) { // 子項右移
        TextView textView = holder.getView(R.id.tvMinorItem);
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams();
        params.leftMargin = ScreenUtils.dpToPxInt(25);
        textView.setLayoutParams(params);
    }
}
 
開發者ID:ynztlxdeai,項目名稱:TextReader,代碼行數:18,代碼來源:MinorAdapter.java

示例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);
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:20,代碼來源:ThemeDialogActivity.java

示例6: onBindViewHolder

import android.widget.TextView; //導入方法依賴的package包/類
@Override
public void onBindViewHolder (RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            LogViewHolder logViewHolder = (LogViewHolder) holder;
            LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            ProgressCard log = logs.get(position);
            ((LogViewHolder) holder).setWeightTitle(log.getTitle());
            progress = log.getProgress();
            for (short i = 0; i < progress.size(); i++) {
                TextView newWeight = new TextView(((LogViewHolder) holder).getLinearLayout().getContext());
                newWeight.setText(String.valueOf(progress.get(i)) + "lbs");
                newWeight.setTextSize(42);
                newWeight.setLayoutParams(lparams);
                logViewHolder.linearLayoutWeigghts.addView(newWeight);
            }
            break;
        case 2:
            ProgressViewHolder progressViewHolder = (ProgressViewHolder) holder;
            progressViewHolder.setWeightTitle(logs.get(position).getTitle());
    }

}
 
開發者ID:Durian-Inc,項目名稱:SwolyV2,代碼行數:25,代碼來源:ProgressAdapter.java

示例7: 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

示例8: 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

示例9: addItemView

import android.widget.TextView; //導入方法依賴的package包/類
private View addItemView(int rid, String text) {
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setId(rid);
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, DensityUtil.dip2px(context, 44f)));
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setBackgroundResource(R.drawable.base_item_bg_selector);
    linearLayout.setOnClickListener(this);
    TextView textView = new TextView(context);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
    textView.setText(text);
    textView.setTextColor(context.getResources().getColor(R.color.bottom_dialog_textcolor));
    textView.setTextSize(16f);
    textView.setGravity(Gravity.CENTER);
    linearLayout.removeAllViews();
    linearLayout.addView(textView);
    return  linearLayout;
}
 
開發者ID:ebridfighter,項目名稱:GongXianSheng,代碼行數:18,代碼來源:CustomBottomDialog.java

示例10: 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:QMUI,項目名稱:QMUI_Android,代碼行數:26,代碼來源:QDDialogFragment.java

示例11: createTextView

import android.widget.TextView; //導入方法依賴的package包/類
private TextView createTextView(Context context, String s, int minHeight, int marginTop, int marginBottom, int marginLeftRight) {
    TextView tv = new TextView(context);
    LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(marginLeftRight, marginTop, marginLeftRight, marginBottom);
    tv.setLayoutParams(params);
    tv.setText(s);
    tv.setGravity(Gravity.CENTER);
    tv.setMinHeight(minHeight);
    tv.setTextAppearance(mContext, R.style.TextAppearance_AppCompat_Caption);
    return tv;

}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:14,代碼來源:MainActivity.java

示例12: showEmptyView

import android.widget.TextView; //導入方法依賴的package包/類
@Override
public void showEmptyView() {
    TextView textView = new TextView(ReviewActivity.this);
    textView.setText(R.string.string_empty_tips);
    textView.setTextSize(30);
    textView.setBackgroundColor(Color.WHITE);
    textView.setGravity(Gravity.CENTER);
    ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    textView.setLayoutParams(lp);
    ((ViewGroup)(findViewById(android.R.id.content))).addView(textView);
}
 
開發者ID:stdnull,項目名稱:RunMap,代碼行數:12,代碼來源:ReviewActivity.java

示例13: createLabelView

import android.widget.TextView; //導入方法依賴的package包/類
protected TextView createLabelView() {
    TextView labelView = new TextView(activity);
    labelView.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
    labelView.setTextColor(textColorFocus);
    labelView.setTextSize(textSize);
    return labelView;
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:8,代碼來源:WheelPicker.java

示例14: addResultListItem

import android.widget.TextView; //導入方法依賴的package包/類
public void addResultListItem(String title, String value, LinearLayout  netLayout) {
	final float scale = activity.getResources().getDisplayMetrics().density;
    final int leftRightItem = Helperfunctions.dpToPx(5, scale);
    final int topBottomItem = Helperfunctions.dpToPx(5, scale);
    final int leftRightDiv = Helperfunctions.dpToPx(0, scale);
    final int topBottomDiv = Helperfunctions.dpToPx(0, scale);
    final int heightDiv = Helperfunctions.dpToPx(1, scale);        
    final int topBottomImg = Helperfunctions.dpToPx(1, scale);
    
    final LinearLayout netItemLayout = new LinearLayout(activity); 
    
    netItemLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    netItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem, topBottomItem);
    
    netItemLayout.setGravity(Gravity.CENTER_VERTICAL);
    
    final TextView itemTitle = new TextView(activity, null, R.style.listResultItemTitle);
    itemTitle.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT, 0.4f));
    itemTitle.setWidth(0);
    itemTitle.setGravity(Gravity.LEFT);
    itemTitle.setText(title);
    
    netItemLayout.addView(itemTitle);
    
    final ImageView itemClassification = new ImageView(activity);
    itemClassification.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT, 0.1f));
    itemClassification.setPadding(0, topBottomImg, 0, topBottomImg);
    
    itemClassification.setImageDrawable(activity.getResources().getDrawable(
            R.drawable.traffic_lights_none));
    netItemLayout.addView(itemClassification);
    
    final TextView itemValue = new TextView(activity, null, R.style.listResultItemValue);
    itemValue.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT, 0.5f));
    itemValue.setWidth(0);
    itemValue.setGravity(Gravity.LEFT);
    itemValue.setText(value);
    
    netItemLayout.addView(itemValue);
    
    netLayout.addView(netItemLayout);
    
    final View divider = new View(activity);
    divider.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv,
            1));
    divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv);
    
    divider.setBackgroundResource(R.drawable.bg_trans_light_10);
    
    netLayout.addView(divider);
    
    netLayout.invalidate();
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:58,代碼來源:RMBTResultPagerAdapter.java

示例15: addAttachmentToInput

import android.widget.TextView; //導入方法依賴的package包/類
void addAttachmentToInput(@NonNull IAct_AInput pA_Customerly_Activity) {
    pA_Customerly_Activity._Attachments.add(this);
    TextView tv = new TextView(pA_Customerly_Activity);
    tv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.io_customerly__ld_chat_attachment, 0, 0, 0);
    int _5dp = IU_Utils.px(5);
    tv.setCompoundDrawablePadding(_5dp);
    tv.setPadding(_5dp, 0, 0, 0);
    tv.setTextColor(IU_Utils.getColorStateListFromResource(pA_Customerly_Activity.getResources(), R.color.io_customerly__textcolor_malibu_grey));
    tv.setLines(1);
    tv.setSingleLine();
    tv.setEllipsize(TextUtils.TruncateAt.MIDDLE);
    tv.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
    tv.setText(this.name);
    tv.setOnClickListener(textView -> new AlertDialog.Builder(pA_Customerly_Activity)
            .setTitle(R.string.io_customerly__choose_a_file_to_attach)
            .setMessage(pA_Customerly_Activity.getString(R.string.io_customerly__cancel_attachment, tv.getText()))
            .setNegativeButton(R.string.io_customerly__cancel, null)
            .setPositiveButton(R.string.io_customerly__remove, (dlg, which) -> {
                ViewGroup vg = (ViewGroup)tv.getParent();
                if(vg != null) {
                    vg.removeView(tv);
                }
                pA_Customerly_Activity._Attachments.remove(this);
            })
            .setCancelable(true)
            .show());
    pA_Customerly_Activity.input_attachments.addView(tv);
}
 
開發者ID:customerly,項目名稱:Customerly-Android-SDK,代碼行數:30,代碼來源:IE_Attachment.java


注:本文中的android.widget.TextView.setLayoutParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。