Headertab

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Saturday, 2 April 2016

CanvasCircle (ImageBitmapCircle)

Hello guys today we are learn about how to create circle text and image bitmap in circle.
This is the most challenging work for beginner developer.


activity_canvas.xml

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.samset.canvascircle.CircleWithCanvas">


    <com.samset.canvascircle.customview.CompassView
        android:id="@+id/cmp"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_centerInParent="true" />
    <TextView
        android:padding="10dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="By samset" />


</RelativeLayout>


CanvasActivity.java

    /*
 * Copyright (C) 2016 by Samset
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 */

package com.samset.canvascircle;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class CircleWithCanvas extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_circle_with_canvas);
    }
}



activity_canvasbitmap.xml

   <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.samset.canvascircle.CircleWithImageBitmap_Activity">

    <ImageView
        android:id="@+id/img"
        android:layout_centerInParent="true"
        android:layout_below="@+id/cmp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:padding="10dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="By samset" />

</RelativeLayout>



CanvasBitmap.java

    /*
 * Copyright (C) 2016 by Samset
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 */

package com.samset.canvascircle;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

import com.samset.canvascircle.customview.CompassView;

public class CircleWithImageBitmap_Activity extends AppCompatActivity {

    private Bitmap bitmap,mybit;
    private CompassView compassView;
    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_circle_with_image_bitmap_);

        imageView= (ImageView) findViewById(R.id.img);
        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.news);
        compassView=new CompassView(this);
        mybit=compassView.getCircularBitmap(bitmap);

        imageView.setImageBitmap(mybit);
    }
}


Thank you.

I hope this blog very helps you.

Full source code

Download here


Live Sample