Border over a bitmap with rounded corners in Android

I put the following together for myself. public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int color, int cornerDips, int borderDips, Context context) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); final int borderSizePx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) borderDips, context.getResources().getDisplayMetrics()); final int cornerSizePx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) cornerDips, context.getResources().getDisplayMetrics()); final Paint paint = new … Read more

How to programmatically round corners and set random background colors

Instead of setBackgroundColor, retrieve the background drawable and set its color: v.setBackgroundResource(R.drawable.tags_rounded_corners); GradientDrawable drawable = (GradientDrawable) v.getBackground(); if (i % 2 == 0) { drawable.setColor(Color.RED); } else { drawable.setColor(Color.BLUE); } Also, you can define the padding within your tags_rounded_corners.xml: <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <corners android:radius=”4dp” /> <padding android:top=”2dp” android:left=”2dp” android:bottom=”2dp” android:right=”2dp” /> </shape>

Android XML rounded clipped corners

2018 Update A lot has changed in the last 7 years. The best way to handle this type of layout these days is to use CardView which has built in support for rounded corners and many other newer UI features as well. Apply the cardCornerRadius property to set the corners to round. <android.support.v7.widget.CardView ……. app:cardCornerRadius=”16dp”> … Read more

Create a rounded button / button with border-radius in Flutter

1. Solution Summary FlatButton and RaisedButton are deprecated. So, you can use shape which placed in the style property, for TextButton and ElevatedButton. There are some changes since Flutter 2.0: style: the property type has changed to ButtonStyle shape: the property type has changed to MaterialStateProperty<T> 2. Rounded Button Inside the style property exists the … Read more

svg / d3.js rounded corners on one side of a rectangle

Expanding on @robert-longson’s answer, you can use SVG’s elliptical arc commands to make the corners, in conjunction with lineto commands for the straight edges. These are used with path elements. Here’s one possible implementation: // Returns path data for a rectangle with rounded right corners. // The top-left corner is ⟨x,y⟩. function rightRoundedRect(x, y, width, … Read more

The border-radius property and border-collapse:collapse don’t mix. How can I use border-radius to create a collapsed table with rounded corners?

I figured it out. You just have to use some special selectors. The problem with rounding the corners of the table was that the td elements didn’t also become rounded. You can solve that by doing something like this: table tr:last-child td:first-child { border: 2px solid orange; border-bottom-left-radius: 10px; } table tr:last-child td:last-child { border: … Read more