Java Code Examples for android.widget.TextView.setLayoutParams()

The following are Jave code examples for showing how to use setLayoutParams() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: QMUI_Android   File: QDPopupFragment.java   View Source Code Vote up 6 votes
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));
            }
        });
    }
}
 
Example 2
Project: AliZhiBoHao   File: LiveCameraActivity.java   View Source Code Vote up 6 votes
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);
}
 
Example 3
Project: go-jay   File: ToastProgress.java   View Source Code Vote up 6 votes
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);
}
 
Example 4
Project: TextReader   File: MinorAdapter.java   View Source Code Vote up 6 votes
@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);
    }
}
 
Example 5
Project: springreplugin   File: ThemeDialogActivity.java   View Source Code Vote up 6 votes
@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);
}
 
Example 6
Project: SwolyV2   File: ProgressAdapter.java   View Source Code Vote up 6 votes
@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());
    }

}
 
Example 7
Project: YCDialog   File: DialogAdapter.java   View Source Code Vote up 6 votes
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);
}
 
Example 8
Project: GitHub   File: SlidingTabLayout.java   View Source Code Vote up 6 votes
/**
 * 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;
}
 
Example 9
Project: GongXianSheng   File: CustomBottomDialog.java   View Source Code Vote up 6 votes
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;
}
 
Example 10
Project: QMUI_Android   File: QDDialogFragment.java   View Source Code Vote up 6 votes
@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;
}
 
Example 11
Project: MyCalendar   File: MainActivity.java   View Source Code Vote up 5 votes
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;

}
 
Example 12
Project: RunMap   File: ReviewActivity.java   View Source Code Vote up 5 votes
@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);
}
 
Example 13
Project: CXJPadProject   File: WheelPicker.java   View Source Code Vote up 5 votes
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;
}
 
Example 14
Project: open-rmbt   File: RMBTResultPagerAdapter.java   View Source Code Vote up 5 votes
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();
}
 
Example 15
Project: Customerly-Android-SDK   File: IE_Attachment.java   View Source Code Vote up 5 votes
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);
}
 
Example 16
Project: BookReader-master   File: RVPIndicator.java   View Source Code Vote up 5 votes
/**
 * 创建标题view
 *
 * @param text
 * @return
 */
private TextView createTextView(String text) {
    TextView tv = new TextView(getContext());
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    lp.width = getWidth() / mTabVisibleCount;
    tv.setGravity(Gravity.CENTER);
    tv.setTextColor(mTextColorNormal);
    tv.setText(text);
    tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextSize);
    tv.setLayoutParams(lp);
    return tv;
}
 
Example 17
Project: Android-FilterView   File: ExtraSectionAdapter.java   View Source Code Vote up 4 votes
private LinearLayout buildViewBoolean(final ExtraBoolean object){
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);

    LinearLayout.LayoutParams linearLayoutParams =
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT);
    linearLayoutParams.height = 200;
    linearLayoutParams.setMargins(0, 0, 0, 0);
    linearLayout.setLayoutParams(linearLayoutParams);
    linearLayout.setPadding(22, 22, 22, 22);

    TypedValue typedValue = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.selectableItemBackground, typedValue, true);
    linearLayout.setBackgroundResource(typedValue.resourceId);

    TextView textView = new TextView(context);
    textView.setText(object.getTitle());

    LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT);

    params.weight = 1;

    textView.setLayoutParams(params);
    textView.setGravity(Gravity.CENTER_VERTICAL);
    textView.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
    textView.setTextSize(16);

    final CheckBox checkBox = new CheckBox(context);
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if(object.getOnBooleanCheckedChangeListener() != null){
                object.getOnBooleanCheckedChangeListener().onChecked(isChecked);
            }


            try {
                section.getResult().put("type", "extra");
                section.getResult().put("section", section.getId());
                section.getResult().put(String.valueOf(object.getId()), isChecked);
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    });

    linearLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkBox.setChecked(!checkBox.isChecked());
        }
    });

    linearLayout.addView(textView);
    linearLayout.addView(checkBox);

    return linearLayout;
}
 
Example 18
Project: Amaro   File: Appoinments.java   View Source Code Vote up 4 votes
private void setAppointmentTexts()
{
    //Set the dynamic layout with appointment texts
    if(fireBaseMap!=null) {
        for (String s : appointmentTexts) {
            //Card view of the dynamic layout
            CardView cardView = new CardView(Appoinments.this);
            LinearLayout.LayoutParams lp = (new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    150));
            lp.setMargins(18, 20, 18, 20);
            cardView.setLayoutParams(lp);
            cardView.setCardBackgroundColor(0xff63D5C3);
            cardView.setPadding(30, 30, 30, 30);

            //Text view of the dynamic layout
            TextView textView = new TextView(Appoinments.this);
            LinearLayout.LayoutParams layoutParams = (new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT));
            textView.setLayoutParams(layoutParams);
            textView.setGravity(Gravity.CENTER);
            textView.setText(s);
            textView.setTextColor(0xff000000); // hex color 0xAARRGGBB
            textView.setTextSize(16);
            textView.setTypeface(Typeface.create("monospace", Typeface.NORMAL));

            //Add the text view to card view
            cardView.addView(textView);


            //Add the card view to linear layout
            verticalLayout.addView(cardView);


        }

        //Set the number of appointments to a text view
        String numberOfAppointments = getString(R.string.appointment) + String.valueOf(listOfAppointments.size());
        appointmentTextView.setText(numberOfAppointments);
    }

}
 
Example 19
Project: GitHub   File: BaseActivity.java   View Source Code Vote up 4 votes
@CallSuper
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LogUtils.verbose(className + " onCreate");
    for (LifeCycleListener listener : lifeCycleListeners) {
        listener.onActivityCreated(this);
    }
    context = getApplicationContext();
    activity = this;
    //不显示标题栏
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (Build.VERSION.SDK_INT >= 21) {
        setTheme(android.R.style.Theme_Material_Light_NoActionBar);
    } else if (Build.VERSION.SDK_INT >= 13) {
        setTheme(android.R.style.Theme_Holo_Light_NoActionBar);
    } else {
        setTheme(android.R.style.Theme_Light_NoTitleBar);
    }
    //被系统回收后重启恢复
    if (savedInstanceState != null) {
        LogUtils.verbose("savedInstanceState is not null");
        onStateRestore(savedInstanceState);
    }
    //显示界面布局
    View contentView = getContentView();
    if (contentView == null) {
        TextView textView = new TextView(this);
        textView.setBackgroundColor(Color.RED);
        textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        textView.setGravity(Gravity.CENTER);
        textView.setText("请先初始化内容视图");
        textView.setTextColor(Color.WHITE);
        contentView = textView;
    }
    LogUtils.verbose(className + " setContentView before");
    setContentViewBefore();
    setContentView(contentView);
    if (isTranslucentStatusBar()) {
        StatusBar.translucent(activity, ContextCompat.getColor(this,R.color.blue));
    }
    setContentViewAfter(contentView);
    LogUtils.verbose(className + " setContentView after");
}
 
Example 20
Project: android_Json2view   File: TextViewProcess.java   View Source Code Vote up 4 votes
public  View createComponentView(Context context, ViewGroup parent, XViewBody yiew) {
    TextView view = new TextView(context);
    ViewGroup.LayoutParams params = Utils.createLayoutParams(parent, yiew);
    view.setLayoutParams(params);




    ViewProcess.applyView(view, yiew);
    LayoutProcess.applyaLayout(view, params, yiew);

    applyTextView(view, yiew);


    return view;
}