Hello what I want to do is add a "scroll bar" to the right hand side of of the screen via java not XML layout how would I accomplish this?
preferably with comments so I can learn from it and not just copy + paste it in.
Code:
package com.jordan.t;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Typeface;
import android.view.View;
public class Main extends View {
Bitmap b1;
Bitmap b2;
Bitmap b3;
Typeface font;
public Main(Context context) {
super(context);
b1 = BitmapFactory.decodeResource(getResources(), R.drawable.blackwool);
b2 = BitmapFactory.decodeResource(getResources(), R.drawable.bluewool);
b3 = BitmapFactory.decodeResource(getResources(), R.drawable.brownwool);
font = Typeface.createFromAsset(context.getAssets(), "G-Unit.TTF");
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.WHITE);
Paint textPaint = new Paint();
textPaint.setARGB(50, 254, 10, 50);
textPaint.setTextAlign(Align.LEFT);
textPaint.setTextSize(30);
textPaint.setTypeface(font);
canvas.drawText("Black Wool", 0, 30, textPaint);
canvas.drawText("Blue Wool", 0, 280, textPaint);
canvas.drawText("Blue Wool", 0, 520, textPaint);
canvas.drawBitmap(b1, 0, 50, null);
canvas.drawBitmap(b2, 0, 290, null);
canvas.drawBitmap(b3, 0, 530, null);
invalidate();
}
}