1

Text over bitmap with some functionality like text color and size change over bitmap.Please give me any suggestion to do or any github reference link

enter image description here

Ankita Shah
  • 1,866
  • 16
  • 31
Lavanya Velusamy
  • 333
  • 1
  • 6
  • 16

2 Answers2

2

I have done such work on one of my application. I have shared code over here...

You have to replace TextView with ImageView used in my code.

Let me know if you stuck somewhere...

Happy Coding :)

Community
  • 1
  • 1
RBK
  • 2,481
  • 2
  • 30
  • 52
0

Use SlopeTextView instead of normal text view. Try this:

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.TextView;

public class SlopeTextView extends TextView{
    final boolean topDown;

    public SlopeTextView(Context context, AttributeSet attrs){
        super(context, attrs);
        final int gravity = getGravity();
        if(Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) {
            setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP);
            topDown = false;
        }else
            topDown = true;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
        super.onMeasure(heightMeasureSpec, widthMeasureSpec);
        setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
    }

    @Override
    protected boolean setFrame(int l, int t, int r, int b){
        return super.setFrame(l, t, l+(b-t), t+(r-l));
    }

    @Override
    public void draw(Canvas canvas){

        Paint paint = new Paint(); 
        paint.setTypeface(Typeface.DEFAULT);
        paint.setStyle(Paint.Style.FILL); 
        canvas.rotate(-45,getHeight(),0);
        super.onDraw(canvas); 
    }
}

Implementation:

<com.example.myviews.SlopeTextView
                    android:id="@+id/slopeTextView"
                    android:layout_width="60dp"
                    android:layout_height="70dp"
                    android:layout_marginTop="5dp"
                    android:gravity="left|top"
                    android:text="Featured"
                    android:textColor="@color/white"
                    android:textSize="@dimen/text_medium" />
mohitum
  • 936
  • 2
  • 12
  • 26