Java Code Examples for android.widget.LinearLayout.setBackgroundDrawable()

The following are Jave code examples for showing how to use setBackgroundDrawable() of the android.widget.LinearLayout 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: MedicationReminder   File: SwipeMenuView.java   View Source Code Vote up 6 votes
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);
	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
Example 2
Project: SwipeMenuAndPullToRefresh   File: SMView.java   View Source Code Vote up 6 votes
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);
	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
Example 3
Project: SwipeMenuAndPullToRefresh   File: SMExpandView.java   View Source Code Vote up 6 votes
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);

	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
Example 4
Project: GongXianSheng   File: SwipeMenuView.java   View Source Code Vote up 6 votes
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);
	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
Example 5
Project: RoadLab-Pro   File: SwipeMenuView.java   View Source Code Vote up 6 votes
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);
	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
Example 6
Project: BBSSDK-for-Android   File: Theme0StyleModifier.java   View Source Code Vote up 5 votes
public static void modifyUniformBlueStyle(BasePageWithTitle basepage) {
	if (basepage == null) {
		return;
	}
	Context context = basepage.getContext();
	TitleBar titlebar = basepage.getTitleBar();
	LinearLayout mainlayout = basepage.getMainLayout();
	if (titlebar == null) {
		throw new IllegalArgumentException("titleBar is not initialized!");
	} else {
		titlebar.setBackgroundColor(Color.TRANSPARENT);
		titlebar.getTitleTextView().setTextColor(context.getResources().getColor(basepage.getColorId("bbs_white")));
		setTextSize(titlebar.getTitleTextView(), "bbs_theme0_title_txt_size");
	}

	if (mainlayout == null) {
		throw new IllegalArgumentException("mainLayout is not initialized!");
	} else {
		Drawable drawable = context.getResources().getDrawable(basepage.getDrawableId("bbs_theme0_bg_userpage"));
		if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
			mainlayout.setBackgroundDrawable(drawable);
		} else {
			mainlayout.setBackground(drawable);
		}
	}
	basepage.setStatusBarColor(context.getResources().getColor(basepage.getColorId("bbs_theme0_statusbar_blue")));
}
 
Example 7
Project: BBSSDK-for-Android   File: Theme0StyleModifier.java   View Source Code Vote up 5 votes
public static void modifyUniformWhiteStyle(BasePageWithTitle basepage) {
	if (basepage == null) {
		return;
	}
	Context context = basepage.getContext();
	TitleBar titlebar = basepage.getTitleBar();
	LinearLayout mainlayout = basepage.getMainLayout();
	if (titlebar == null) {
		throw new IllegalArgumentException("titleBar is not initialized!");
	} else {
		titlebar.setBackgroundColor(Color.TRANSPARENT);
		if(titlebar.getTitleTextView() != null) {
			titlebar.getTitleTextView().setTextColor(context.getResources().getColor(basepage.getColorId("bbs_theme0_pagetext")));
			setTextSize(titlebar.getTitleTextView(), "bbs_theme0_title_txt_size");
		}
	}

	if (mainlayout == null) {
		throw new IllegalArgumentException("mainLayout is not initialized!");
	} else {
		ColorDrawable drawable = new ColorDrawable(context.getResources().getColor(basepage.getColorId("bbs_white")));
		if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
			mainlayout.setBackgroundDrawable(drawable);
		} else {
			mainlayout.setBackground(drawable);
		}
	}
	basepage.setStatusBarColor(BBSViewBuilder.getInstance().getStatusBarColor(context));
}
 
Example 8
Project: BBSSDK-for-Android   File: Theme1StyleModifier.java   View Source Code Vote up 5 votes
public static void modifyUniformWhiteStyle(BasePageWithTitle basepage) {
	if (basepage == null) {
		return;
	}
	Context context = basepage.getContext();
	TitleBar titlebar = basepage.getTitleBar();
	LinearLayout mainlayout = basepage.getMainLayout();
	if (titlebar == null) {
		throw new IllegalArgumentException("titleBar is not initialized!");
	} else {
		titlebar.setBackgroundColor(Color.TRANSPARENT);
		if(titlebar.getTitleTextView() != null) {
			titlebar.getTitleTextView().setTextColor(context.getResources().getColor(basepage.getColorId("bbs_theme1_pagetext")));
			setTextSize(titlebar.getTitleTextView(), "bbs_theme1_title_txt_size");
		}
	}

	if (mainlayout == null) {
		throw new IllegalArgumentException("mainLayout is not initialized!");
	} else {
		ColorDrawable drawable = new ColorDrawable(context.getResources().getColor(basepage.getColorId("bbs_white")));
		if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
			mainlayout.setBackgroundDrawable(drawable);
		} else {
			mainlayout.setBackground(drawable);
		}
	}
	basepage.setStatusBarColor(context.getResources().getColor(basepage.getColorId("bbs_theme1_statusbar")));
}
 
Example 9
Project: BBSSDK-for-Android   File: AnotherActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(ResHelper.getLayoutRes(this, "bbs_theme1_activity_another"));
	layoutContainer = (LinearLayout) findViewById(ResHelper.getIdRes(this, "layoutContainer"));
	Drawable drawable = new BitmapDrawable(getResources(), BlurEffectManager.getInstance().getBlurFrontPage());
	layoutContainer.setBackgroundDrawable(drawable);
}
 
Example 10
Project: MovingGdufe-Android   File: ScheduleView.java   View Source Code Vote up 5 votes
/**
     * 获取单个课表View
     *
     * @param model 数据类型
     * @return
     */
    @SuppressWarnings("deprecation")
    private View getMode(final Schedule model) {
        LinearLayout mScheduleView = new LinearLayout(getContext());
        mScheduleView.setOrientation(VERTICAL);
        TextView mTimeTableNameView = new TextView(getContext());
        int num = model.getEndSec() - model.getStartSec();
        mTimeTableNameView.setHeight(dip2px((num + 1) * TimeTableHeight) + num * 2);
        mTimeTableNameView.setTextColor(getContext().getResources().getColor(
                android.R.color.white));
        mTimeTableNameView.setWidth(dip2px(50));
        mTimeTableNameView.setTextSize(CourseTextSize);
        mTimeTableNameView.setGravity(Gravity.CENTER);
        mTimeTableNameView.setText(model.getName() + "\n" + model.getLocation());
        mScheduleView.addView(mTimeTableNameView);
        mScheduleView.addView(getWeekTransverseLine());
        mScheduleView.setBackgroundDrawable(getContext().getResources()
                .getDrawable(colors[getColorNum(model.getName())]));

        if(mCurrentWeek != FileUtils.SP_WEEK_NOT_SET && !CalcUtils.isCurrentWeek(model.getPeriod(), mCurrentWeek)){
            mScheduleView.setBackgroundDrawable(getContext().getResources()
                    .getDrawable(notGocolors));
//            mTimeTableNameView.setTextColor(getContext().getResources().getColor(
//                    android.R.color.darker_gray));
        }

        mScheduleView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
//                Toast.makeText(getContext(), model.getName() + "\n" + model.getLocation()+"\n" +model.getPeriod()+"\n"+ model.getTeacher(), Toast.LENGTH_SHORT).show();
                //TODO 编辑课程
                mClickListener.onClickScheduleEdit(model);
            }
        });
        return mScheduleView;
    }
 
Example 11
Project: Shared-Route   File: NormalListDialog.java   View Source Code Vote up 5 votes
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final DialogMenuItem item = contents.get(position);

    LinearLayout ll_item = new LinearLayout(context);
    ll_item.setOrientation(LinearLayout.HORIZONTAL);
    ll_item.setGravity(Gravity.CENTER_VERTICAL);

    ImageView iv_item = new ImageView(context);
    iv_item.setPadding(0, 0, dp2px(15), 0);
    ll_item.addView(iv_item);

    TextView tv_item = new TextView(context);
    tv_item.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    tv_item.setSingleLine(true);
    tv_item.setTextColor(itemTextColor);
    tv_item.setTextSize(TypedValue.COMPLEX_UNIT_SP, itemTextSize_SP);

    ll_item.addView(tv_item);
    float radius = dp2px(cornerRadius_DP);
    if (isTitleShow) {
        ll_item.setBackgroundDrawable((CornerUtils.listItemSelector(radius, Color.TRANSPARENT, itemPressColor,
                position == contents.size() - 1)));
    } else {
        ll_item.setBackgroundDrawable(CornerUtils.listItemSelector(radius, Color.TRANSPARENT, itemPressColor,
                contents.size(), position));
    }

    int left = item.resId == 0 ? dp2px(18) : dp2px(16);
    int top = dp2px(10);
    int right = 0;
    int bottom = dp2px(10);
    ll_item.setPadding(left + itemExtraLeft, top + itemExtraTop, right + itemExtraRight, bottom + itemExtraBottom);

    iv_item.setImageResource(item.resId);
    tv_item.setText(item.operName);
    iv_item.setVisibility(item.resId == 0 ? View.GONE : View.VISIBLE);

    return ll_item;
}
 
Example 12
Project: PWEditText-SafeKeyboard   File: SafetyKeyboard.java   View Source Code Vote up 4 votes
/**
 * 密码键盘默认样式
 * @param context
 */
private void initView(Context context) {
    mkeyboardLayout = new LinearLayout(context);
    mkeyboardLayout.setOrientation(LinearLayout.VERTICAL);
    if (null != mKeyBoardBgDrawable) {
        mkeyboardLayout.setBackgroundDrawable(mKeyBoardBgDrawable);
    } else {
        mkeyboardLayout.setBackgroundColor(Color.GRAY);
    }
    LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    titleParams.setMargins(0, 0, 0, 6);
    mTitleLayout = new LinearLayout(context);
    mTitleLayout.setGravity(Gravity.CENTER);
    mTitleLayout.setOrientation(LinearLayout.HORIZONTAL);

    mTitleLayout.setLayoutParams(titleParams);
    int titleBackgroundColor = mContext.getResources()
            .getColor(R.color.bg_security_keyboard_title);
    mTitleLayout.setBackgroundColor(titleBackgroundColor);
    mTitleView = new TextView(context);
    mTitleView.setText("Secure Mode");
    mTitleView.setTextColor(Color.WHITE);
    mTitleView.setHeight(getSaftyKeyHeight() / 16);
    mTitleView.setGravity(Gravity.CENTER);
    mTitleLayout.addView(mTitleView);

    mKeyBoardControl = new GrapeGridview(context);
    mKeyBoardControl.setHorizontalScrollBarEnabled(false);
    mKeyBoardControl.setVerticalScrollBarEnabled(false);
    mKeyBoardControl.setEnabled(false);
    mKeyBoardControl.setNumColumns(Constant.COLUMN_SOFT_KEYBOARD);
    mKeyBoardControl.setVerticalSpacing(mMarginRow);
    mKeyBoardControl.setHorizontalSpacing(mMarginCol);
    mKeyBoardControl.setAdapter(mAdapter);

    mkeyboardLayout.addView(mTitleLayout);
    mkeyboardLayout.addView(mKeyBoardControl);
    mkeyboardLayout.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight,
            mPaddingBottom);

    mPopup = new PopupWindow(mkeyboardLayout, mWidth, mHeight);
    mPopup.setBackgroundDrawable(new BitmapDrawable());
    mPopup.setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    mPopup.setOutsideTouchable(true);
    mPopup.setFocusable(true);
    mPopup.setOnDismissListener(dismissListener);
}
 
Example 13
Project: ywApplication   File: PlatformListPage.java   View Source Code Vote up 4 votes
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);

	// cancel button
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xff3a65ff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	int resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, com.mob.tools.utils.R.dipToPx(getContext(), 5));

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

	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(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}
 
Example 14
Project: airgram   File: PickerBottomLayout.java   View Source Code Vote up 4 votes
public PickerBottomLayout(Context context, boolean darkTheme) {
    super(context);
    isDarkTheme = darkTheme;

    setBackgroundColor(isDarkTheme ? 0xff1a1a1a : 0xffffffff);

    cancelButton = new TextView(context);
    cancelButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    cancelButton.setTextColor(isDarkTheme ? 0xffffffff : 0xff19a7e8);
    cancelButton.setGravity(Gravity.CENTER);
    cancelButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false));
    cancelButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
    cancelButton.setTypeface(FontManager.instance().getTypeface());
    addView(cancelButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));

    doneButton = new LinearLayout(context);
    doneButton.setOrientation(LinearLayout.HORIZONTAL);
    doneButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false));
    doneButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT));

    doneButtonBadgeTextView = new TextView(context);
    doneButtonBadgeTextView.setTypeface(FontManager.instance().getTypeface());
    doneButtonBadgeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    doneButtonBadgeTextView.setTextColor(0xffffffff);
    doneButtonBadgeTextView.setGravity(Gravity.CENTER);
    doneButtonBadgeTextView.setBackgroundResource(isDarkTheme ? R.drawable.photobadge : R.drawable.bluecounter);
    doneButtonBadgeTextView.setMinWidth(AndroidUtilities.dp(23));
    doneButtonBadgeTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), AndroidUtilities.dp(1));
    doneButton.addView(doneButtonBadgeTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 23, Gravity.CENTER_VERTICAL, 0, 0, 10, 0));

    doneButtonTextView = new TextView(context);
    doneButtonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    doneButtonTextView.setTextColor(isDarkTheme ? 0xffffffff : 0xff19a7e8);
    doneButtonTextView.setGravity(Gravity.CENTER);
    doneButtonTextView.setCompoundDrawablePadding(AndroidUtilities.dp(8));
    doneButtonTextView.setText(LocaleController.getString("Send", R.string.Send).toUpperCase());
    doneButtonTextView.setTypeface(FontManager.instance().getTypeface());
    doneButton.addView(doneButtonTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));
}
 
Example 15
Project: KrGallery   File: PickerBottomLayout.java   View Source Code Vote up 4 votes
public PickerBottomLayout(Context context, boolean darkTheme) {
    super(context);
    isDarkTheme = darkTheme;

    setBackgroundColor(isDarkTheme ? 0xff1a1a1a : 0xffffffff);

    cancelButton = new TextView(context);
    cancelButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    cancelButton.setTextColor(isDarkTheme ? 0xffffffff : 0xff007aff);
    cancelButton.setGravity(Gravity.CENTER);
    cancelButton.setBackgroundDrawable(
            Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR
                    : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false));
    cancelButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    cancelButton.setText(R.string.Preview);
    // cancelButton.getPaint().setFakeBoldText(true);
    addView(cancelButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));

    doneButton = new LinearLayout(context);
    doneButton.setOrientation(LinearLayout.HORIZONTAL);
    doneButton.setBackgroundDrawable(
            Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR
                    : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false));
    doneButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT));

    doneButtonBadgeTextView = new TextView(context);
    // doneButtonBadgeTextView.getPaint().setFakeBoldText(true);
    doneButtonBadgeTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    doneButtonBadgeTextView.setTextColor(0xffffffff);
    doneButtonBadgeTextView.setGravity(Gravity.CENTER);
    doneButtonBadgeTextView.setBackgroundResource(
            isDarkTheme ? R.drawable.photobadge_new : R.drawable.photobadge_new);
    doneButtonBadgeTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8),
            AndroidUtilities.dp(1));
    doneButton.addView(doneButtonBadgeTextView,
            LayoutHelper.createLinear(26, 26, Gravity.CENTER_VERTICAL, 0, 0, 10, 0));

    doneButtonTextView = new TextView(context);
    doneButtonTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    doneButtonTextView.setTextColor(isDarkTheme ? 0xffffffff : 0xff007aff);
    doneButtonTextView.setGravity(Gravity.CENTER);
    doneButtonTextView.setCompoundDrawablePadding(AndroidUtilities.dp(8));
    doneButtonTextView.setText(R.string.Send);
    // doneButtonTextView.getPaint().setFakeBoldText(true);
    doneButton.addView(doneButtonTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));
}
 
Example 16
Project: PlusGram   File: PickerBottomLayout.java   View Source Code Vote up 4 votes
public PickerBottomLayout(Context context, boolean darkTheme) {
    super(context);
    isDarkTheme = darkTheme;

    setBackgroundColor(isDarkTheme ? 0xff1a1a1a : 0xffffffff);

    cancelButton = new TextView(context);
    cancelButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    cancelButton.setTextColor(isDarkTheme ? 0xffffffff : 0xff19a7e8);
    cancelButton.setGravity(Gravity.CENTER);
    cancelButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false));
    cancelButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
    cancelButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    addView(cancelButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));

    doneButton = new LinearLayout(context);
    doneButton.setOrientation(LinearLayout.HORIZONTAL);
    doneButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false));
    doneButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT));

    doneButtonBadgeTextView = new TextView(context);
    doneButtonBadgeTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    doneButtonBadgeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    doneButtonBadgeTextView.setTextColor(0xffffffff);
    doneButtonBadgeTextView.setGravity(Gravity.CENTER);
    doneButtonBadgeTextView.setBackgroundResource(isDarkTheme ? R.drawable.photobadge : R.drawable.bluecounter);
    doneButtonBadgeTextView.setMinWidth(AndroidUtilities.dp(23));
    doneButtonBadgeTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), AndroidUtilities.dp(1));
    doneButton.addView(doneButtonBadgeTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 23, Gravity.CENTER_VERTICAL, 0, 0, 10, 0));

    doneButtonTextView = new TextView(context);
    doneButtonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    doneButtonTextView.setTextColor(isDarkTheme ? 0xffffffff : 0xff19a7e8);
    doneButtonTextView.setGravity(Gravity.CENTER);
    doneButtonTextView.setCompoundDrawablePadding(AndroidUtilities.dp(8));
    doneButtonTextView.setText(LocaleController.getString("Send", R.string.Send).toUpperCase());
    doneButtonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    doneButton.addView(doneButtonTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));
}