List of usage examples for android.graphics.drawable ShapeDrawable setIntrinsicWidth
public void setIntrinsicWidth(int width)
From source file:Main.java
/** * Make circle drawable for badge background * * @param color background color//from www.j av a 2 s . c o m * @return return colored circle drawable */ static ShapeDrawable makeShapeDrawable(int color) { ShapeDrawable badgeBackground = new ShapeDrawable(new OvalShape()); badgeBackground.setIntrinsicWidth(10); badgeBackground.setIntrinsicHeight(10); badgeBackground.getPaint().setColor(color); return badgeBackground; }
From source file:Main.java
public static ShapeDrawable getShapeDrawable(int size, int color) { ShapeDrawable circle = new ShapeDrawable(new OvalShape()); circle.setIntrinsicHeight(size);/*from ww w. ja v a 2 s . c o m*/ circle.setIntrinsicWidth(size); circle.getPaint().setColor(color); return circle; }
From source file:com.hellofyc.base.util.ViewUtils.java
public static ShapeDrawable make(int size, int color) { ShapeDrawable indicator = new ShapeDrawable(new OvalShape()); indicator.setIntrinsicWidth(size); indicator.setIntrinsicHeight(size);/* w w w.ja va 2s . com*/ indicator.getPaint().setColor(color); return indicator; }
From source file:com.gm.grecyclerview.GmRecyclerView.java
private void addDividerItemDecoration(@ColorInt int color, int orientation, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) { DividerItemDecoration decor = new DividerItemDecoration(getContext(), orientation); if (color != 0) { ShapeDrawable shapeDrawable = new ShapeDrawable(new RectShape()); shapeDrawable.setIntrinsicHeight(Utils.dpToPx(getContext(), 1)); shapeDrawable.setIntrinsicWidth(Utils.dpToPx(getContext(), 1)); shapeDrawable.getPaint().setColor(color); InsetDrawable insetDrawable = new InsetDrawable(shapeDrawable, paddingLeft, paddingTop, paddingRight, paddingBottom);/*from w ww . j a v a 2 s. c o m*/ decor.setDrawable(insetDrawable); } decor.setShowLastDivider(showLastDivider); addItemDecoration(decor); }
From source file:com.google.samples.apps.iosched.ui.SessionDetailActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;//from w ww . ja v a 2 s . co m } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); // TODO: better encapsulation Intent intent = new Intent(SessionDetailActivity.this, BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }
From source file:com.ncode.android.apps.schedo.ui.EventDetailActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;// www .j a v a 2 s.c om } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); // TODO: better encapsulation Intent intent = new Intent(EventDetailActivity.this, BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }
From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;//from w w w . j a v a 2s . c o m } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); // TODO: better encapsulation Intent intent = new Intent(CurrentSessionActivity.this, BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }
From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null || !isAdded()) { return;/* ww w . jav a 2 s .co m*/ } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(getActivity()); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { getActivity().finish(); // TODO: better encapsulation Intent intent = new Intent(getActivity(), BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }
From source file:com.saarang.samples.apps.iosched.ui.SessionDetailActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;/* w ww . j av a 2 s. c o m*/ } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater .inflate(com.saarang.samples.apps.iosched.R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); // TODO: better encapsulation Intent intent = new Intent(SessionDetailActivity.this, BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }
From source file:com.skytree.epubtest.BookViewActivity.java
public void makeControls() { this.removeControls(); Theme theme = getCurrentTheme();//www . j a va 2s .co m int bs = 38; if (this.isRotationLocked) rotationButton = this.makeImageButton(9000, R.drawable.rotationlocked2x, ps(42), ps(42)); else rotationButton = this.makeImageButton(9000, R.drawable.rotation2x, ps(42), ps(42)); listButton = this.makeImageButton(9001, R.drawable.list2x, getPS(bs), getPS(bs)); fontButton = this.makeImageButton(9002, R.drawable.font2x, getPS(bs), getPS(bs)); searchButton = this.makeImageButton(9003, R.drawable.search2x, getPS(bs), getPS(bs)); rotationButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(rotationButton)); listButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(listButton)); fontButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(fontButton)); searchButton.setOnTouchListener(new ImageButtonHighlighterOnTouchListener(searchButton)); titleLabel = this.makeLabel(3000, title, Gravity.CENTER_HORIZONTAL, 17, Color.argb(240, 94, 61, 35)); // setTextSize in android uses sp (Scaled Pixel) as default, they say that sp guarantees the device dependent size, but as usual in android it can't be 100% sure. authorLabel = this.makeLabel(3000, author, Gravity.CENTER_HORIZONTAL, 17, Color.argb(240, 94, 61, 35)); pageIndexLabel = this.makeLabel(3000, "......", Gravity.CENTER_HORIZONTAL, 13, Color.argb(240, 94, 61, 35)); secondaryIndexLabel = this.makeLabel(3000, "......", Gravity.CENTER_HORIZONTAL, 13, Color.argb(240, 94, 61, 35)); // rv.customView.addView(rotationButton); // rv.customView.addView(listButton); // rv.customView.addView(fontButton); // rv.customView.addView(searchButton); rv.customView.addView(titleLabel); rv.customView.addView(authorLabel); ePubView.addView(rotationButton); ePubView.addView(listButton); ePubView.addView(fontButton); if (!rv.isScrollMode()) ePubView.addView(searchButton); // ePubView.addView(titleLabel); // ePubView.addView(authorLabel); ePubView.addView(pageIndexLabel); ePubView.addView(secondaryIndexLabel); seekBar = new SkySeekBar(this); seekBar.setMax(999); seekBar.setId(999); RectShape rectShape = new RectShape(); ShapeDrawable thumb = new ShapeDrawable(rectShape); thumb.getPaint().setColor(theme.seekThumbColor); thumb.setIntrinsicHeight(getPS(28)); thumb.setIntrinsicWidth(getPS(28)); seekBar.setThumb(thumb); seekBar.setBackgroundColor(Color.TRANSPARENT); seekBar.setOnSeekBarChangeListener(new SeekBarDelegate()); seekBar.setProgressDrawable(new DottedDrawable(theme.seekBarColor)); seekBar.setThumbOffset(-3); seekBar.setMinimumHeight(24); int filterColor = theme.controlColor; rotationButton.setColorFilter(filterColor); listButton.setColorFilter(filterColor); fontButton.setColorFilter(filterColor); searchButton.setColorFilter(filterColor); authorLabel.setTextColor(filterColor); titleLabel.setTextColor(filterColor); pageIndexLabel.setTextColor(filterColor); secondaryIndexLabel.setTextColor(filterColor); ePubView.addView(seekBar); }