In this Android Studio article i want to show you Creating Social Buttons.
So after this article when you are developing Android applications, you will be able to add
Social Button in your application. for adding Social Buttons in your android application we are
going to use a third party library.
Learn How to Create Animated Submit Button in Android Studio
Also you can read more android development articles
1: Android Development Articles
So lets get started !
1: First of all create a new project in your Android Studio, and choose Empty Activity
2: After that open your build.gradle (Module:app) and in the dependencies section
you need to add this library.
1 |
com.shaishavgandhi:login-buttons:1.0.0 |
So after adding that your gradle will look like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "com.forogh.parwiz.socialbuttons" minSdkVersion 20 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.shaishavgandhi:login-buttons:1.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } |
3: The next step is to open your activity_main.xml from your layout folder and add these xml
codes to that and it will looks like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <LinearLayout android:layout_width="368dp" android:layout_height="495dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:orientation="vertical" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <com.shaishavgandhi.loginbuttons.FacebookButton android:layout_marginTop = "20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="center" app:iconSize = "30sp" android:text="Sign In With Facebook" /> <com.shaishavgandhi.loginbuttons.GoogleButton android:layout_marginTop="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="center" app:iconSize = "30sp" android:text="Sign In With Google" android:textColor="@android:color/holo_red_dark" /> <com.shaishavgandhi.loginbuttons.TwitterButton android:layout_marginTop="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="center" app:iconSize = "30sp" android:text="Sign In With Twitter" /> <com.shaishavgandhi.loginbuttons.LinkedInButton android:layout_marginTop="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="center" app:iconSize = "30sp" android:text="Sign In With Linkedin" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:layout_marginTop="50dp" > <com.shaishavgandhi.loginbuttons.FacebookButton android:layout_width="75dp" android:layout_height="75dp" app:iconSize = "30sp" /> <com.shaishavgandhi.loginbuttons.TwitterButton android:layout_width="75dp" android:layout_height="75dp" app:iconSize = "30sp" android:layout_marginLeft="10dp" /> <com.shaishavgandhi.loginbuttons.GoogleButton android:layout_width="75dp" android:layout_height="75dp" app:iconSize = "30sp" android:layout_marginLeft="10dp" /> <com.shaishavgandhi.loginbuttons.LinkedInButton android:layout_width="75dp" android:layout_height="75dp" app:iconSize = "30sp" /> </LinearLayout> </LinearLayout> </android.support.constraint.ConstraintLayout> |
These are the main codes for creating of our four Social Buttons.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
<com.shaishavgandhi.loginbuttons.FacebookButton android:layout_marginTop = "20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="center" app:iconSize = "30sp" android:text="Sign In With Facebook" /> <com.shaishavgandhi.loginbuttons.GoogleButton android:layout_marginTop="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="center" app:iconSize = "30sp" android:text="Sign In With Google" android:textColor="@android:color/holo_red_dark" /> <com.shaishavgandhi.loginbuttons.TwitterButton android:layout_marginTop="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="center" app:iconSize = "30sp" android:text="Sign In With Twitter" /> <com.shaishavgandhi.loginbuttons.LinkedInButton android:layout_marginTop="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="center" app:iconSize = "30sp" android:text="Sign In With Linkedin" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:layout_marginTop="50dp" > <com.shaishavgandhi.loginbuttons.FacebookButton android:layout_width="75dp" android:layout_height="75dp" app:iconSize = "30sp" /> <com.shaishavgandhi.loginbuttons.TwitterButton android:layout_width="75dp" android:layout_height="75dp" app:iconSize = "30sp" android:layout_marginLeft="10dp" /> <com.shaishavgandhi.loginbuttons.GoogleButton android:layout_width="75dp" android:layout_height="75dp" app:iconSize = "30sp" android:layout_marginLeft="10dp" /> <com.shaishavgandhi.loginbuttons.LinkedInButton android:layout_width="75dp" android:layout_height="75dp" app:iconSize = "30sp" /> </LinearLayout> |
You don’t need to bring changes in your other files of Android Studio like MainActivity.java.
Run the complete code and it will be like this.
Also you can Watch the complete video for this article
Subscribe and Get Free Video Courses & Articles in your Email