Circle Button in Android Example |Android App Development With AndroidCource

Monday, 18 June 2018

Circle Button in Android Example

How To Create Circle Button in android example.

Creating Circle Button Style And Implements Ripple Effect When Button is Click to Effect in button and change custom size in button and change custom color.

Add Dependancy in Module Level build.gradle File

compile 'com.github.markushi:circlebutton:1.1'

MainActivity.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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.bhaumik.circlebutton.MainActivity">

    <at.markushi.ui.CircleButton
        android:layout_width="130dp"
        android:layout_height="130dp"
        app:cb_color="@color/colorAccent"
        app:cb_pressedRingWidth="10dp"
        android:src="@drawable/ic_home"
        android:id="@+id/btn_home"
        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="160dp"
        android:id="@+id/btn_ripple"
        android:layout_marginTop="10dp"
        android:background="@drawable/ripples"
        android:text="Java"
        android:textColor="#FFF"
        android:textAllCaps="false" />

</RelativeLayout>

MainActivity.java

package com.bhaumik.circlebutton;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import at.markushi.ui.CircleButton;

public class MainActivity extends AppCompatActivity {

    CircleButton btn;

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

        btn = (CircleButton) findViewById(R.id.btn_home);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this,"Home Button Clicked....",Toast.LENGTH_SHORT).show();
            }
        });


    }
}
Circle Button in android example

0 comments:

Post a Comment