Java Code Examples for android.widget.Button#setTextSize()

The following examples show how to use android.widget.Button#setTextSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaterialDialog.java    From DialogUtil with Apache License 2.0 6 votes vote down vote up
/**
 * set negative button
 *
 * @param text the name of button
 */
public void setNegativeButton(String text, final View.OnClickListener listener) {
    Button button = new Button(mContext);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    button.setLayoutParams(params);
    button.setBackgroundResource(R.drawable.material_card);
    button.setText(text);
    button.setTextColor(Color.argb(222, 0, 0, 0));
    button.setTextSize(14);
    button.setGravity(Gravity.CENTER);
    button.setPadding(0, 0, 0, dip2px(8));
    button.setOnClickListener(listener);
    if (mButtonLayout.getChildCount() > 0) {
        params.setMargins(20, 0, 10, dip2px(BUTTON_BOTTOM));
        button.setLayoutParams(params);
        mButtonLayout.addView(button, 1);
    } else {
        button.setLayoutParams(params);
        mButtonLayout.addView(button);
    }
}
 
Example 2
Source File: Ubuntu.java    From heads-up with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void addActionButton(ViewGroup actionButtons, String actionTitle, Drawable icon, View.OnClickListener clickListener, float fontMultiplier) {
    LayoutInflater inflater = LayoutInflater.from(actionButtons.getContext());
    ViewGroup v = (ViewGroup) inflater.inflate(
            R.layout.button_notification, actionButtons);

    Button button = (Button) v.getChildAt(v.getChildCount() - 1);
    button.setText(actionTitle);
    button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontMultiplier * button.getTextSize());
    button.setTextColor(Color.WHITE);
    if (icon != null) {
        icon.mutate().setColorFilter(getColorFilter(Color.WHITE));
        button.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
    }
    button.setOnClickListener(clickListener);
}
 
Example 3
Source File: ToolUtils.java    From KUtils-master with Apache License 2.0 6 votes vote down vote up
/**
 * 设置MD风格样式
 */
public static void setMdBtnStytle(BuildBean bean) {
    Button btnPositive =
            bean.alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
    Button btnNegative =
            bean.alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    Button btnNatural =
            bean.alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
    if (btnPositive != null && btnNegative != null) {
        btnPositive.setTextSize(bean.btnTxtSize);
        btnNegative.setTextSize(bean.btnTxtSize);
        btnNatural.setTextSize(bean.btnTxtSize);
        if (bean.btn1Color != 0)
            btnPositive.setTextColor(getColor(null, bean.btn1Color));
        if (bean.btn2Color != 0)
            btnNegative.setTextColor(getColor(null, bean.btn2Color));
        if (bean.btn3Color != 0)
            btnNatural.setTextColor(getColor(null, bean.btn3Color));
    }
    Window window = bean.alertDialog.getWindow();
    window.setGravity(bean.gravity);
}
 
Example 4
Source File: ToolUtils.java    From KUtils with Apache License 2.0 6 votes vote down vote up
/**
 * 设置MD风格样式
 */
public static void setMdBtnStytle(BuildBean bean) {
    Button btnPositive =
            bean.alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
    Button btnNegative =
            bean.alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    Button btnNatural =
            bean.alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
    if (btnPositive != null && btnNegative != null) {
        btnPositive.setTextSize(bean.btnTxtSize);
        btnNegative.setTextSize(bean.btnTxtSize);
        btnNatural.setTextSize(bean.btnTxtSize);
        if (bean.btn1Color != 0)
            btnPositive.setTextColor(getColor(null, bean.btn1Color));
        if (bean.btn2Color != 0)
            btnNegative.setTextColor(getColor(null, bean.btn2Color));
        if (bean.btn3Color != 0)
            btnNatural.setTextColor(getColor(null, bean.btn3Color));
    }
    Window window = bean.alertDialog.getWindow();
    window.setGravity(bean.gravity);
}
 
Example 5
Source File: L5Light.java    From heads-up with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void addActionButton(ViewGroup actionButtons, String actionTitle, Drawable icon, View.OnClickListener clickListener, float fontMultiplier) {
    LayoutInflater inflater = LayoutInflater.from(actionButtons.getContext());
    ViewGroup v = (ViewGroup) inflater.inflate(
            R.layout.button_notification, actionButtons);

    Button button = (Button) v.getChildAt(v.getChildCount() - 1);
    button.setText(actionTitle);
    button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontMultiplier * button.getTextSize());
    button.setTextColor(Color.BLACK);
    //Typeface typeface = Typeface.createFromAsset(actionButtons.getContext().getAssets(), "RobotoCondensed-Regular.ttf");
    //button.setTypeface(typeface);
    if (icon != null) {
        icon.mutate().setColorFilter(getColorFilter(Color.DKGRAY));
        button.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
    }
    button.setOnClickListener(clickListener);
}
 
Example 6
Source File: BasicActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
protected void beautyButtonGreen(Button mButton, String str, OnClickListener mOnClickListener) {
    mButton.setText(str);
    mButton.setTextSize(16.0f);
    mButton.setOnClickListener(mOnClickListener);
    SDKUtils.setBackground(mButton, this.crMgmt.getStatusDrawable("common_btn_blue_pressed", "common_btn_blue_normal", true));
    mButton.setTextColor(this.crMgmt.createSelector("#ffffff", "#ffffff"));
}
 
Example 7
Source File: ColorPicker.java    From colorpicker with Apache License 2.0 5 votes vote down vote up
/**
 * add a new Button using default style
 *
 * @param text     title of button
 * @param listener OnButtonListener
 * @return this
 */
public ColorPicker addListenerButton(String text, final OnButtonListener listener) {
    if (mContext == null)
        return this;

    Context context = mContext.get();
    if (context == null)
        return this;


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

    params.setMargins(dip2px(10, context), 0, 0, 0);
    Button button = new Button(context);
    button.setMinWidth(getDimensionDp(R.dimen.action_button_min_width, context));
    button.setMinimumWidth(getDimensionDp(R.dimen.action_button_min_width, context));
    button.setPadding(
            getDimensionDp(R.dimen.action_button_padding_horizontal, context) + dip2px(5, context), 0,
            getDimensionDp(R.dimen.action_button_padding_horizontal, context) + dip2px(5, context), 0);
    button.setBackgroundResource(R.drawable.button);
    button.setTextSize(getDimensionDp(R.dimen.action_button_text_size, context));
    button.setTextColor(ContextCompat.getColor(context, R.color.black_de));

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            listener.onClick(v, colorViewAdapter.getColorPosition(), colorViewAdapter.getColorSelected());
        }
    });
    button.setText(text);
    if (button.getParent() != null)
        buttons_layout.removeView(button);

    buttons_layout.addView(button);
    button.setLayoutParams(params);
    return this;
}
 
Example 8
Source File: AmountView.java    From AmmountView with Apache License 2.0 5 votes vote down vote up
public AmountView(Context context, AttributeSet attrs) {
    super(context, attrs);

    LayoutInflater.from(context).inflate(R.layout.view_amount, this);
    etAmount = (EditText) findViewById(R.id.etAmount);
    btnDecrease = (Button) findViewById(R.id.btnDecrease);
    btnIncrease = (Button) findViewById(R.id.btnIncrease);
    btnDecrease.setOnClickListener(this);
    btnIncrease.setOnClickListener(this);
    etAmount.addTextChangedListener(this);

    TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.AmountView);
    int btnWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_btnWidth, LayoutParams.WRAP_CONTENT);
    int tvWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_tvWidth, 80);
    int tvTextSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_tvTextSize, 0);
    int btnTextSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AmountView_btnTextSize, 0);
    obtainStyledAttributes.recycle();

    LayoutParams btnParams = new LayoutParams(btnWidth, LayoutParams.MATCH_PARENT);
    btnDecrease.setLayoutParams(btnParams);
    btnIncrease.setLayoutParams(btnParams);
    if (btnTextSize != 0) {
        btnDecrease.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnTextSize);
        btnIncrease.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnTextSize);
    }

    LayoutParams textParams = new LayoutParams(tvWidth, LayoutParams.MATCH_PARENT);
    etAmount.setLayoutParams(textParams);
    if (tvTextSize != 0) {
        etAmount.setTextSize(tvTextSize);
    }
}
 
Example 9
Source File: MaterialDialog.java    From DialogUtil with Apache License 2.0 5 votes vote down vote up
/**
 * set positive button
 *
 * @param text the name of button
 */
public void setPositiveButton(String text, final View.OnClickListener listener) {
    Button button = new Button(mContext);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    button.setLayoutParams(params);
    button.setBackgroundResource(R.drawable.material_card);
    button.setTextColor(Color.argb(255, 35, 159, 242));
    button.setText(text);
    button.setGravity(Gravity.CENTER);
    button.setTextSize(14);
    button.setPadding(dip2px(12), 0, dip2px(32), dip2px(BUTTON_BOTTOM));
    button.setOnClickListener(listener);
    mButtonLayout.addView(button);
}
 
Example 10
Source File: DialogUtils.java    From Field-Book with GNU General Public License v2.0 5 votes vote down vote up
public static void setButtonSize(AlertDialog dialog) {
    int buttonSize = 19;

    Button buttonPos =  dialog.getButton(AlertDialog.BUTTON_POSITIVE);
    buttonPos.setTextSize(buttonSize);
    Button buttonNeg =  dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    buttonNeg.setTextSize(buttonSize);
    Button buttonNeu =  dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
    buttonNeu.setTextSize(buttonSize);
}
 
Example 11
Source File: SentenceQuizActivity.java    From 10000sentences with Apache License 2.0 5 votes vote down vote up
private void adjustFontSize() {
    for (String lang : Constants.LANGS_WITH_LARGER_FONTS) {
        if (targetLanguage.languageId.equals(lang)) {
            for (Button answerButton : answerButtons) {
                answerButton.setTextSize(answerButton.getTextSize() * 1.2F);
            }
            binding.targetSentence.setTextSize(binding.targetSentence.getTextSize() * 1.2F);
        }
    }
}
 
Example 12
Source File: ConfirmDialog.java    From luckymoney with Apache License 2.0 5 votes vote down vote up
private Button getButton(Context context, String text, View.OnClickListener listener) {
    int padding = (int) (8 * mDensity + .5f);

    Button button = new Button(context);
    button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15.f);
    button.setTextColor(0xFF333333);
    button.setText(text);
    button.setBackgroundResource(R.drawable.item_highlight_bkg);
    button.setPadding(0, padding, 0, padding);
    button.setOnClickListener(listener);

    return button;
}
 
Example 13
Source File: OverlayShowingService.java    From VoIpUSSD with Apache License 2.0 5 votes vote down vote up
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent.hasExtra(EXTRA))
        tittle = intent.getStringExtra(EXTRA);
    wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    Point size = new Point();
    wm.getDefaultDisplay().getSize(size);
    int LAYOUT_FLAG;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        LAYOUT_FLAG = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
    } else {
        LAYOUT_FLAG = WindowManager.LayoutParams.TYPE_PHONE;
    }
    overlayedButton = new Button(this);
    overlayedButton.setText(tittle);
    overlayedButton.setAlpha(0.7f);
    overlayedButton.setBackgroundColor(0xFFFFFFFF);
    overlayedButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 26);

    WindowManager.LayoutParams params =
            new WindowManager.LayoutParams
                    (WindowManager.LayoutParams.MATCH_PARENT,
                            size.y - 200,
                            LAYOUT_FLAG
                            , WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
                            PixelFormat.TRANSLUCENT);

    params.gravity = Gravity.CENTER | Gravity.CENTER;
    wm.addView(overlayedButton, params);
    return START_STICKY;
}
 
Example 14
Source File: ResUtils.java    From QNotified with GNU General Public License v3.0 4 votes vote down vote up
public static void applyStyleCommonBtnBlue(Button btn) {
    btn.setBackgroundDrawable(getCommonBtnBlueBackground());
    btn.setTextColor(skin_color_button_blue);
    btn.setTextSize(17);
    btn.setMinHeight(dip2px(btn.getContext(), 42));
}
 
Example 15
Source File: DialogLayer.java    From FidoCadJ with GNU General Public License v3.0 4 votes vote down vote up
/** Get a custom View showing the useful information about the
    layers: color and visibility.
    @param position the ordinal position in the list (layer number)
    @param convertView
    @param parent the parent component.
    @return the custom view.
*/
public View getCustomView(int pos,
                        View convertView, ViewGroup parent)
{
    final int position=pos;
    LayoutInflater inflater =
        ((Activity) context).getLayoutInflater();
    final View row = inflater.inflate(R.layout.layer_spinner_item,
        parent, false);

    row.setBackgroundColor(Color.WHITE);

    // Here we show a small rectangle of the layer color
    SurfaceView sv =
        (SurfaceView) row.findViewById(R.id.surface_view);
    sv.setBackgroundColor(layers.get(position).getColor().getRGB());
    // A text element showing the layer name, in black if the
    // layer is visible or in gray if it is not.
    Button b = (Button) row.findViewById(R.id.name_item);
    b.setText(layers.get(position).getDescription());
    b.setOnClickListener(new SpecSelectCurrentLayer(drawingPanel,
        layerButton, layers, diag, position));

    // We have a switch which determines whether a layer is visible
    // or not.
    Switch ss = (Switch) row.findViewById(R.id.visibility_item);

    ss.setChecked(layers.get(position).isVisible);
    ss.setOnCheckedChangeListener(
        new SpecCheckedChangeListener(convertView,
            layers, position));

    b.setTextColor(Color.BLACK);

    b.setBackgroundColor(Color.WHITE);
    b.setTextSize(20);

    Button edit = (Button) row.findViewById(R.id.edit_item);
    edit.setOnClickListener(new View.OnClickListener()
    {
        /** Create a new layer editing dialog and show it.
        */
        @Override
        public void onClick(View v)
        {
            drawingPanel.eea.currentLayer = position;
            // show layer dialog
            DialogEditLayer dl = new DialogEditLayer(position, row);
            dl.show(getFragmentManager(), "");
        }
    });

    return row;
}
 
Example 16
Source File: OnekeyShare.java    From ShareSDKShareDifMsgDemo-Android with MIT License 4 votes vote down vote up
private void initPageView() {
	flPage = new FrameLayout(getContext());
	flPage.setOnClickListener(this);

	// 宫格列表的容器,为了“下对齐”,在外部包含了一个FrameLayout
	LinearLayout llPage = new LinearLayout(getContext()) {
		public boolean onTouchEvent(MotionEvent event) {
			return true;
		}
	};
	llPage.setOrientation(LinearLayout.VERTICAL);
	int resId = getBitmapRes(getContext(), "share_vp_back");
	if (resId > 0) {
		llPage.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpLl.gravity = Gravity.BOTTOM;
	llPage.setLayoutParams(lpLl);
	flPage.addView(llPage);

	// 宫格列表
	grid = new PlatformGridView(getContext());
	grid.setEditPageBackground(bgView);
	LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	grid.setLayoutParams(lpWg);
	llPage.addView(grid);

	// 取消按钮
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xffffffff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
	resId = getBitmapRes(getContext(), "btn_cancel_back");
	if (resId > 0) {
		btnCancel.setBackgroundResource(resId);
	}
	LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
	lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}
 
Example 17
Source File: TimePickerView.java    From Android-PickerView with Apache License 2.0 4 votes vote down vote up
private void initView(Context context) {
    setDialogOutSideCancelable();
    initViews();
    initAnim();

    if (mPickerOptions.customListener == null) {
        LayoutInflater.from(context).inflate(R.layout.pickerview_time, contentContainer);

        //顶部标题
        TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
        RelativeLayout rv_top_bar = (RelativeLayout) findViewById(R.id.rv_topbar);

        //确定和取消按钮
        Button btnSubmit = (Button) findViewById(R.id.btnSubmit);
        Button btnCancel = (Button) findViewById(R.id.btnCancel);

        btnSubmit.setTag(TAG_SUBMIT);
        btnCancel.setTag(TAG_CANCEL);

        btnSubmit.setOnClickListener(this);
        btnCancel.setOnClickListener(this);

        //设置文字
        btnSubmit.setText(TextUtils.isEmpty(mPickerOptions.textContentConfirm) ? context.getResources().getString(R.string.pickerview_submit) : mPickerOptions.textContentConfirm);
        btnCancel.setText(TextUtils.isEmpty(mPickerOptions.textContentCancel) ? context.getResources().getString(R.string.pickerview_cancel) : mPickerOptions.textContentCancel);
        tvTitle.setText(TextUtils.isEmpty(mPickerOptions.textContentTitle) ? "" : mPickerOptions.textContentTitle);//默认为空

        //设置color
        btnSubmit.setTextColor(mPickerOptions.textColorConfirm);
        btnCancel.setTextColor(mPickerOptions.textColorCancel);
        tvTitle.setTextColor(mPickerOptions.textColorTitle);
        rv_top_bar.setBackgroundColor(mPickerOptions.bgColorTitle);

        //设置文字大小
        btnSubmit.setTextSize(mPickerOptions.textSizeSubmitCancel);
        btnCancel.setTextSize(mPickerOptions.textSizeSubmitCancel);
        tvTitle.setTextSize(mPickerOptions.textSizeTitle);

    } else {
        mPickerOptions.customListener.customLayout(LayoutInflater.from(context).inflate(mPickerOptions.layoutRes, contentContainer));
    }
    // 时间转轮 自定义控件
    LinearLayout timePickerView = (LinearLayout) findViewById(R.id.timepicker);
    timePickerView.setBackgroundColor(mPickerOptions.bgColorWheel);

    initWheelTime(timePickerView);
}
 
Example 18
Source File: PlatformListPage.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
private void initPageView() {
		flPage = new FrameLayout(getContext());
		flPage.setOnClickListener(this);
		flPage.setBackgroundDrawable(new ColorDrawable(0x55000000));

		// container of the platform gridview
		llPage = new LinearLayout(getContext()) {
			public boolean onTouchEvent(MotionEvent event) {
				return true;
			}
		};
		llPage.setOrientation(LinearLayout.VERTICAL);
		llPage.setBackgroundDrawable(new ColorDrawable(0xffffffff));
		FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
				FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
		lpLl.gravity = Gravity.BOTTOM;
		llPage.setLayoutParams(lpLl);
		flPage.addView(llPage);

		// gridview
		grid = new PlatformGridView(getContext());
		grid.setEditPageBackground(getBackgroundView());
		LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
		grid.setLayoutParams(lpWg);
		llPage.addView(grid);

		View line_view = new View(getContext());
		line_view.setBackgroundDrawable(new ColorDrawable(0xffd5d5d5));

		int lineHeight = (int)((float)0.5 * getContext().getResources().getDisplayMetrics().density + 0.5F);

		LinearLayout.LayoutParams lpLine = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT, lineHeight);
		int dp_10 = com.mob.tools.utils.R.dipToPx(getContext(), 10);
		lpLine.setMargins(0, dp_10, 0, 0);
		line_view.setLayoutParams(lpLine);
		llPage.addView(line_view);

		// cancel button
		btnCancel = new Button(getContext());
		ColorStateList csl=(ColorStateList)activity.getResources().getColorStateList(R.color.z_txt_input);
		btnCancel.setTextColor(csl);
		btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
		int resId = getStringRes(getContext(), "cancel");
		if (resId > 0) {
			btnCancel.setText(resId);
		}
		btnCancel.setPadding(0, 0, 0, 0);

		resId = getBitmapRes(getContext(), "classic_platform_corners_bg");
		if(resId > 0){
			btnCancel.setBackgroundResource(resId);
		}else {
		    btnCancel.setBackgroundDrawable(new ColorDrawable(0xffffffff));
		}
		btnCancel.setBackgroundColor(0x00ffffff);

		LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT, com.mob.tools.utils.R.dipToPx(getContext(), 45));
//		int dp_10 = com.mob.tools.utils.R.dipToPx(getContext(), 10);
		lpBtn.setMargins(0, 0, 0, 0);
		btnCancel.setLayoutParams(lpBtn);
		llPage.addView(btnCancel);
	}
 
Example 19
Source File: CommentListDialog.java    From xposed-aweme with Apache License 2.0 4 votes vote down vote up
@Override
protected View createView(LayoutInflater inflater, ViewGroup container) {

    // 不显示默认标题
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

    mCommonFrameLayout = new CommonFrameLayout(getContext());
    mToolbar = mCommonFrameLayout.getTitleView();
    mMoreButton = mToolbar.addMoreImageButton();

    LinearLayout layout = LayoutUtil.newCommonLayout(getContext());

    FrameLayout headLayout = new FrameLayout(getContext());
    headLayout.setLayoutParams(LayoutUtil.newFrameLayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));

    TextView tvTips = new TextView(getContext());
    tvTips.setTextColor(0xffafafaf);
    tvTips.setTextSize(10f);
    tvTips.setText("提示:单击编辑左滑可删除");

    mAddCommonButton = new Button(getContext());
    mAddCommonButton.setText("添加");
    mAddCommonButton.setTextSize(14f);
    mAddCommonButton.setTextColor(0xFFF93F25);
    mAddCommonButton.setBackgroundColor(0x00000000);

    FrameLayout.LayoutParams tipsParams = LayoutUtil.newWrapFrameLayoutParams();
    tipsParams.leftMargin = DisplayUtil.dip2px(getContext(), 15f);
    tipsParams.gravity = Gravity.CENTER_VERTICAL;

    FrameLayout.LayoutParams params = LayoutUtil.newFrameLayoutParams(
            DisplayUtil.dip2px(getContext(), 70f), DisplayUtil.dip2px(getContext(), 40f));
    params.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;

    headLayout.addView(tvTips, tipsParams);
    headLayout.addView(mAddCommonButton, params);

    mSwipeMenuListView = new SwipeMenuListView(getContext());
    mSwipeMenuListView.setCacheColorHint(0x00000000);
    mSwipeMenuListView.setDividerHeight(0);
    mSwipeMenuListView.setMenuCreator(newMenuCreator());
    mSwipeMenuListView.setCloseInterpolator(new BounceInterpolator());
    mSwipeMenuListView.setLayoutParams(LayoutUtil.newMatchLinearLayoutParams());

    layout.addView(headLayout);
    layout.addView(mSwipeMenuListView);

    mCommonFrameLayout.setContent(layout);

    return mCommonFrameLayout;
}
 
Example 20
Source File: OnekeyShare.java    From -Android_ShareSDK_Example_Wechat with MIT License 4 votes vote down vote up
private void initPageView() {
	flPage = new FrameLayout(getContext());
	flPage.setOnClickListener(this);

	// container of the platform gridview
	LinearLayout llPage = new LinearLayout(getContext()) {
		public boolean onTouchEvent(MotionEvent event) {
			return true;
		}
	};
	llPage.setOrientation(LinearLayout.VERTICAL);
	int resId = getBitmapRes(getContext(), "share_vp_back");
	if (resId > 0) {
		llPage.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpLl.gravity = Gravity.BOTTOM;
	llPage.setLayoutParams(lpLl);
	flPage.addView(llPage);

	// gridview
	grid = new PlatformGridView(getContext());
	LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	grid.setLayoutParams(lpWg);
	llPage.addView(grid);

	// cancel button
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xffffffff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
	resId = getBitmapRes(getContext(), "btn_cancel_back");
	if (resId > 0) {
		btnCancel.setBackgroundResource(resId);
	}
	LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
	lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}