
Designing a Circle Layout Using LinearLayout in Android. Hello all, today i am back with another tutorial in which i am going to design circle layout using LinearLayout. LinearLayout is one of the key element in any android app it plays important role in designing any user interface of app.
So let’s start our tutorial. Designing a Circle Layout Using LinearLayout in Android
What is LinearLayout?
- LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally.
- In the Linear layout all the elements are displayed in linear fashion means all the childs/elements of a linear layout are displayed according to its orientation.
Creating New Android Project (Designing a Circle Layout Using LinearLayout in Android)
- Create a new project in Android Studio File–>New–>New Project.
- Enter Application Name, Package Name, Select Empty Activity and click on finish.
Gradient Background
- Right click on drawable folder–>New–>Drawable resource file.
- Write File Name and click Ok.
- Write following code.
1 2 3 4 5 6 7 8 9 10 11 12 |
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:angle="135" android:startColor="#9649a7" android:endColor="#4957a7" android:type="linear"></gradient> </shape> |
NoActionBar Theme
- Open styles.xml file inside values folder.
- Change parent theme to –
1Theme.AppCompat.NoActionBar
Add Icons
- Add icons to mipmap folder.
- I will provide all the code and icons at the end of the project.
Designing Part
Our layout will contain one Parent Liner Layout which will have three Linear layout.
Parent LinearLayout
- First of all we have to create one LinearLayout which will be our Parent LinearLayout and it’s orientation is set to be “Vertical” because It will have 3 three vertical children.
as you can see in the figure first we need to create a parent linearlayout after that we will create three child linearlayout.
Three LinearLayout inside parent layout
- After first step we will create three linear layout inside parent layout. You can refer to above figure to see how you will do it.
Three LinearLayout inside every child layout
- Inside every child layout we will create three linear layout which will have orientation of vertical. so we will have total nine linear layout which will contain logo and text inside.
Padding at last
- At last we will give padding to every nine linear layout to align them to circle looking design.
Lets Design
- Open activity_main.xml file and put add following code.
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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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="com.androidcodefinder.circledesign.MainActivity" android:orientation="vertical" android:background="@drawable/gradient" android:gravity="center"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="3"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" android:orientation="vertical" android:paddingLeft="30dp" android:paddingTop="30dp"> <ImageView android:layout_width="70dp" android:layout_height="70dp" android:src="@mipmap/led"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Led Tv" android:textColor="@android:color/white"/> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" android:orientation="vertical" android:paddingBottom="60dp"> <ImageView android:layout_width="70dp" android:layout_height="70dp" android:src="@mipmap/furniture"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Furniture" android:textColor="@android:color/white"/> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" android:orientation="vertical" android:paddingRight="30dp" android:paddingTop="30dp"> <ImageView android:layout_width="70dp" android:layout_height="70dp" android:src="@mipmap/hotel"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hotel" android:textColor="@android:color/white"/> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="3"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" android:orientation="vertical" android:paddingRight="30dp"> <ImageView android:layout_width="70dp" android:layout_height="70dp" android:src="@mipmap/flight"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Flight" android:textColor="@android:color/white"/> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" android:orientation="vertical"> <ImageView android:layout_width="100dp" android:layout_height="100dp" android:src="@mipmap/shopping"/> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" android:orientation="vertical" android:paddingLeft="30dp"> <ImageView android:layout_width="70dp" android:layout_height="70dp" android:src="@mipmap/fashion"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Fashion" android:textColor="@android:color/white"/> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="3"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" android:orientation="vertical" android:paddingLeft="30dp" android:paddingTop="30dp"> <ImageView android:layout_width="70dp" android:layout_height="70dp" android:src="@mipmap/beauty"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Beauty" android:textColor="@android:color/white"/> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" android:orientation="vertical" android:paddingTop="60dp"> <ImageView android:layout_width="70dp" android:layout_height="70dp" android:src="@mipmap/phone"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Mobile" android:textColor="@android:color/white"/> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" android:orientation="vertical" android:paddingRight="30dp" android:paddingTop="30dp"> <ImageView android:layout_width="70dp" android:layout_height="70dp" android:src="@mipmap/offer"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Offers" android:textColor="@android:color/white"/> </LinearLayout> </LinearLayout> </LinearLayout> |
Now run the project and enjoy.
Fell free to comment your query.
-
Download Complete Project
Circle Layout Using LinearLayout
Subscribe To Our YouTube Channel
Like Us On Facebook
Other Tutorials-
- Facebook Account Kit SMS Authentication for Android
- Android Cascading Spinners Using Php Mysql
- Android Upload Image To Server Using PHP MySql
- Dashboard Design In Android Studio Using CardView Tutorial
- Android Build Intro Slider Using ViewPager
- Splash Screen Android
- Login Screen Using LinearLayout
- Awesome Login Screen Design Using Constraint Layout
- Firebase phone number authentication in android studio