Draw Doted Lines In Back ground with Image?


Activity.java

  1.  public class MainActivity extends Activity {
    LinearLayout layout;
    DrawView drawView;
    public static Display display;
    int length = 10;

    int width, height, equal_parts_width, equal_parts_height;

    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    drawView = new DrawView(this);
    drawView.setBackgroundColor(Color.BLACK);
    // setContentView(drawView);
    setContentView(R.layout.activity_main);

    layout = (LinearLayout) findViewById(R.id.load);
    layout.addView(drawView);

    display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    width = size.x;
    height = size.y;

    equal_parts_width = width / 10;
    equal_parts_height = height / 10;
    }

    public class DrawView extends View {
    Paint paint = new Paint();

    public DrawView(Context context) {
    super(context);
    paint.setColor(Color.WHITE);
    // paint.setStyle(Style.STROKE);
    paint.setStrokeJoin(Paint.Join.ROUND);
    paint.setStrokeCap(Paint.Cap.ROUND);
    paint.setDither(true);
    paint.setAntiAlias(true);
    }

    @SuppressLint("DrawAllocation")
    @Override
    public void onDraw(Canvas canvas) {
    // float width = canvas.getWidth();
    // float height = canvas.getHeight();
    float size = width / (120 * 2); // just use 14 it's for convenience here
    paint.setPathEffect(new DashPathEffect(new float[] { size, size }, 0));
    for (int i = 0; i < 11; i++) {
    canvas.drawLine(0, equal_parts_height * i, width,equal_parts_height * i, paint);
    canvas.drawLine(equal_parts_width * i, 0, equal_parts_width * i, height, paint);
    }
    }
    }
    }


No comments:

Select DateRange UsingRangePicker.

  /* * This Method is for select range from picker. * */ private fun selectDateRangeUsingRangePicker () { pageNumber = 1 val displ...