List of usage examples for android.graphics.drawable ShapeDrawable setIntrinsicHeight
public void setIntrinsicHeight(int height)
From source file:Main.java
public static ShapeDrawable getShapeDrawable(int size, int color) { ShapeDrawable circle = new ShapeDrawable(new OvalShape()); circle.setIntrinsicHeight(size); circle.setIntrinsicWidth(size);/*from w w w.j ava2 s . c o m*/ circle.getPaint().setColor(color); return circle; }
From source file:Main.java
/** * Make circle drawable for badge background * * @param color background color/*from w w w. 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:com.hellofyc.base.util.ViewUtils.java
public static ShapeDrawable make(int size, int color) { ShapeDrawable indicator = new ShapeDrawable(new OvalShape()); indicator.setIntrinsicWidth(size);// ww w . j av a 2 s. c o m indicator.setIntrinsicHeight(size); indicator.getPaint().setColor(color); return indicator; }
From source file:com.ksharkapps.musicnow.ui.activities.AudioPlayerActivity.java
public static Drawable createDrawable(Context context, int color) { ShapeDrawable shape = new ShapeDrawable(); shape.getPaint().setStyle(Style.FILL); shape.setIntrinsicHeight(1); shape.getPaint().setColor(context.getResources().getColor(R.color.transparent)); shape.getPaint().setStyle(Style.STROKE); shape.getPaint().setStrokeWidth(4);/*from w w w . ja v a 2 s.c o m*/ shape.getPaint().setColor(color); ShapeDrawable shapeD = new ShapeDrawable(); shapeD.getPaint().setStyle(Style.FILL); shapeD.getPaint().setColor(color); ClipDrawable clipDrawable = new ClipDrawable(shapeD, Gravity.LEFT, ClipDrawable.HORIZONTAL); LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { clipDrawable, shape }); return layerDrawable; }
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 w w.j a v a2s. co 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;/* w w w. jav a 2s.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;/* w w w .j ava 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(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 www . j a va 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(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;/*from ww w . 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(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 w w . j a v 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); } } }