List of usage examples for android.graphics.drawable GradientDrawable RECTANGLE
int RECTANGLE
To view the source code for android.graphics.drawable GradientDrawable RECTANGLE.
Click Source Link
From source file:com.bilibili.magicasakura.utils.GradientDrawableInflateImpl.java
void inflateGradientRootElement(Context context, AttributeSet attrs, GradientDrawable gradientDrawable) { int shape = DrawableUtils.getAttrInt(context, attrs, android.R.attr.shape, GradientDrawable.RECTANGLE); gradientDrawable.setShape(shape);// w w w .j av a 2 s .c o m boolean dither = DrawableUtils.getAttrBoolean(context, attrs, android.R.attr.dither, false); gradientDrawable.setDither(dither); }
From source file:io.imoji.sdk.editor.fragment.TagImojiFragment.java
public Drawable createTagDrawable() { GradientDrawable d = new GradientDrawable(); TypedArray a = getActivity().getTheme().obtainStyledAttributes(new int[] { R.attr.colorAccent }); final int accentColor = a.getColor(0, Color.WHITE); a.recycle();//from ww w .j ava 2 s . com d.setColor(0xB3FFFFFF & accentColor); d.setCornerRadius(getResources().getDimension(R.dimen.dim_8dp)); d.setShape(GradientDrawable.RECTANGLE); GradientDrawable d1 = new GradientDrawable(); d1.setCornerRadius(getResources().getDimension(R.dimen.dim_8dp)); d1.setStroke((int) getResources().getDimension(R.dimen.dim_0_5dp), 0x66FFFFFF & Color.BLACK); GradientDrawable d2 = new GradientDrawable(); d2.setStroke((int) getResources().getDimension(R.dimen.dim_1dp), accentColor); d2.setCornerRadius(getResources().getDimension(R.dimen.dim_8dp)); LayerDrawable layer = new LayerDrawable(new Drawable[] { d, d2, d1 }); int halfDp = (int) getResources().getDimension(R.dimen.dim_0_5dp); int oneDp = (int) getResources().getDimension(R.dimen.dim_1dp); int oneAndHalf = halfDp + oneDp; layer.setLayerInset(2, 0, 0, 0, 0); layer.setLayerInset(1, halfDp, halfDp, halfDp, halfDp); layer.setLayerInset(0, oneAndHalf, oneAndHalf, oneAndHalf, oneAndHalf); return layer; }
From source file:com.sonymobile.androidapp.gridcomputing.fragments.ReportChartFragment.java
private void setLegends() { if (mChart.getData().getDataSets().size() > 1) { final Resources resources = ApplicationData.getAppContext().getResources(); final float density = getResources().getDisplayMetrics().density; final float legendWidth = resources.getDimension(R.dimen.chart_legend_width) / density; final float legendHeight = resources.getDimension(R.dimen.chart_legend_height) / density; final float legendMargin = resources.getDimension(R.dimen.chart_legend_margin) / density; final float legendCorner = resources.getDimension(R.dimen.chart_legend_corner) / density; for (ILineDataSet lineDataSet : mChart.getData().getDataSets()) { final CheckBox checkBox = new CheckBox(mLegendLayout.getContext()); checkBox.setChecked(true);//from w w w .ja va 2s . com checkBox.setText(lineDataSet.getLabel()); checkBox.setTag(lineDataSet); checkBox.setOnCheckedChangeListener(mLegendCheckedChangeListener); GradientDrawable drawable = new GradientDrawable(); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setColor(lineDataSet.getColor()); drawable.setSize((int) legendWidth, (int) legendHeight); drawable.setCornerRadius(legendCorner); checkBox.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null); checkBox.setCompoundDrawablePadding((int) legendMargin); final GridLayout.Spec titleTxtSpecColumn = GridLayout.spec(GridLayout.UNDEFINED); final GridLayout.Spec titleRowSpec = GridLayout.spec(GridLayout.UNDEFINED); final GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams(titleRowSpec, titleTxtSpecColumn); layoutParams.setMargins((int) legendWidth, 0, (int) legendWidth, 0); mLegendLayout.addView(checkBox, layoutParams); } } }
From source file:im.vector.adapters.VectorRoomSummaryAdapter.java
/** * Apply a rounded (sides) rectangle as a background to the view provided in aTargetView. * * @param aTargetView view to apply the background * @param aBackgroundColor background colour */// ww w. j a v a2 s .c om private static void setUnreadBackground(View aTargetView, int aBackgroundColor) { if (null != aTargetView) { GradientDrawable shape = new GradientDrawable(); shape.setShape(GradientDrawable.RECTANGLE); shape.setCornerRadius(100); shape.setColor(aBackgroundColor); aTargetView.setBackground(shape); } }
From source file:am.widget.basetabstrip.BaseTabStrip.java
/** * ?Tag//from ww w. j av a 2 s. co m * * @return Tag */ @SuppressWarnings("unused") protected Drawable getDefaultTagBackground() { final float density = getResources().getDisplayMetrics().density; final GradientDrawable mBackground = new GradientDrawable(); mBackground.setShape(GradientDrawable.RECTANGLE); mBackground.setColor(0xffff4444); mBackground.setCornerRadius(100000 * density); mBackground.setSize((int) (10 * density), (int) (10 * density)); return mBackground; }