Android BlurMaskFilter has no effect in canvas.drawOval while text is blurred

Looks like a bug to me. I reported it to the Android team; we’ll see what they say. It renders correctly if you set android:hardwareAccelerated=”false” on your Activity in AndroidManifest.xml. Here is the official word from the Android graphics team: “BlurMaskFilter is not supported with hardware acceleration.” (As of July 10, 2012)

Android : Draw Circle With Text Inside

Try this <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”wrap_content” > <RelativeLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” > <TextView android:id=”@+id/num_txt” android:layout_width=”100dp” android:layout_height=”100dp” android:layout_marginTop=”0dp” android:background=”@drawable/bg_red” android:gravity=”center” android:text=”My name is NON” android:textColor=”#FFFFFF” android:textSize=”10dp” /> </RelativeLayout> </RelativeLayout> Save in drawable bg_red.xml <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”oval”> <corners android:radius=”10dip”/> <stroke android:color=”#FF0000″ android:width=”5dip”/> <solid android:color=”#FF0000″/> </shape> Edited Code <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” … Read more

How to add rectangles on top of existing rectangle in canvas

Try this: public class RectangleTextView extends View { private final Paint mBlackPaint = new Paint(); private final Paint mRedPaint = new Paint(); private final TextPaint mTextPaint; public RectangleTextView(Context context, AttributeSet attrs) { super(context, attrs); int valueInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()); int valueInSp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics()); mRedPaint.setColor(Color.parseColor(“#CC3333”)); mBlackPaint.setAntiAlias(false); mBlackPaint.setColor(Color.BLACK); mBlackPaint.setStrokeWidth(valueInDp); mBlackPaint.setStyle(Paint.Style.STROKE); mTextPaint = … Read more

Crop square image to circle – Programmatically

Once the bitmap is retrieved RoundedBitmapDrawableFactory can be used to generate a RoundedBitmapDrawable from the v4 Support Library. That Drawable can then be applied to an ImageView or directly drawn to a Canvas. // Create the RoundedBitmapDrawable. RoundedBitmapDrawable roundDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap); roundDrawable.setCircular(true); // Apply it to an ImageView. ImageView imageView = (ImageView)findViewById(R.id.imageView); imageView.setImageDrawable(roundDrawable); // … Read more

Adding a colored background with text/icon under swiped row when using Android’s RecyclerView

I was struggling to implement this feature as well, but you steered me in the right direction. @Override public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { // Get RecyclerView item from the ViewHolder View itemView = viewHolder.itemView; Paint p = new … Read more