In this article, we’ll explore how to design a Modern Dashboard UI in Android Studio, using a combination of RelativeLayout, CardView, and custom background styling to create an appealing and user-friendly interface.
Output:
Example of Modern Dashboard UI Design in Android Studio
Now, we will create an android application. Then, we will create modern dashboard UI in Android app.
- Open Android Studio.
- Go to File => New => New Project. Write application name. Then, click next button.
- Select minimum SDK you need. However, we have selected 21 as minimum SDK. Then, click next button
- Then, select Empty Activity => click next => click finish.
- If you have followed above process correctly, you will get a newly created project successfully. However, you can also visit post to create a new project to know steps in detail.
Let’s modify xml and java file to create Modern Dashboard UI Design in Android.
First of all add the below icons or according to your design.
Now create a resource file inside drawable and name it cut_card_background as shown in above image and paste the following code.
1 2 3 4 5 6 7 8 9 10 11 |
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/colorPurple"/> <corners android:topLeftRadius="400dp" android:topRightRadius="0dp"/> </shape> |
it will create one sided curved drawable with a purple color and if you want to change the color then you can.
It’s time to design our Modern Dashboard UI Design in Android, so open you activity_main.xml and paste the 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 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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" android:background="@drawable/cut_card_background" tools:context=".MainActivity"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="My Dashboard" android:textSize="30sp" android:textStyle="bold" android:textColor="@color/colorBlack" android:layout_margin="12dp"/> <GridLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/textView" android:layout_marginTop="20dp" android:layout_margin="20dp" android:columnCount="2" android:rowCount="3"> <androidx.cardview.widget.CardView android:id="@+id/cardHome" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="fill" android:layout_columnWeight="1" android:layout_rowWeight="1" android:layout_row="0" android:layout_column="0" app:cardCornerRadius="8dp" app:cardElevation="8dp" app:cardUseCompatPadding="true"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_home"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Home" android:textSize="16sp" android:textColor="@color/colorBlack"/> </LinearLayout> </androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView android:id="@+id/cardChat" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="fill" android:layout_columnWeight="1" android:layout_rowWeight="1" android:layout_row="0" android:layout_column="1" app:cardCornerRadius="8dp" app:cardElevation="8dp" app:cardUseCompatPadding="true"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_chat"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Chat" android:textSize="16sp" android:textColor="@color/colorBlack"/> </LinearLayout> </androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView android:id="@+id/cardProfile" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="fill" android:layout_columnWeight="1" android:layout_rowWeight="1" android:layout_row="1" android:layout_column="0" app:cardCornerRadius="8dp" app:cardElevation="8dp" app:cardUseCompatPadding="true"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_person"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Profile" android:textSize="16sp" android:textColor="@color/colorBlack"/> </LinearLayout> </androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView android:id="@+id/cardWidget" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="fill" android:layout_columnWeight="1" android:layout_rowWeight="1" android:layout_row="1" android:layout_column="1" app:cardCornerRadius="8dp" app:cardElevation="8dp" app:cardUseCompatPadding="true"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_widget"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Widgets" android:textSize="16sp" android:textColor="@color/colorBlack"/> </LinearLayout> </androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView android:id="@+id/cardSettings" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="fill" android:layout_columnWeight="1" android:layout_rowWeight="1" android:layout_row="2" android:layout_column="0" app:cardCornerRadius="8dp" app:cardElevation="8dp" app:cardUseCompatPadding="true"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_settings"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Settings" android:textSize="16sp" android:textColor="@color/colorBlack"/> </LinearLayout> </androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView android:id="@+id/cardLogout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="fill" android:layout_columnWeight="1" android:layout_rowWeight="1" android:layout_row="2" android:layout_column="1" app:cardCornerRadius="8dp" app:cardElevation="8dp" app:cardUseCompatPadding="true"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:gravity="center" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_logout"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Logout" android:textSize="16sp" android:textColor="@color/colorBlack"/> </LinearLayout> </androidx.cardview.widget.CardView> </GridLayout> </RelativeLayout> |
MainActivity.java:
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 |
public class MainActivity extends AppCompatActivity { CardView cardHome; CardView cardChat; CardView cardProfile; CardView cardWidget; CardView cardSettings; CardView cardLogout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); cardHome = findViewById(R.id.cardHome); cardChat = findViewById(R.id.cardChat); cardProfile = findViewById(R.id.cardProfile); cardWidget = findViewById(R.id.cardWidget); cardSettings = findViewById(R.id.cardSettings); cardLogout = findViewById(R.id.cardLogout); cardHome.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showToast("Home Clicked"); } }); cardChat.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showToast("Chat Clicked"); } }); cardProfile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showToast("Profile Clicked"); } }); cardWidget.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showToast("Widget Clicked"); } }); cardSettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showToast("Settings Clicked"); } }); cardLogout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showToast("Logout Clicked"); } }); } private void showToast(String message) { Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); } } |
XML Layout Structure: The provided XML code outlines the layout structure of the dashboard UI. It utilizes a RelativeLayout as the main container, incorporating various CardView elements to represent different sections of the dashboard. Each CardView includes an ImageView and TextView, providing visual icons and text labels for distinct functionalities.
Custom Background Styling: The XML code also includes a separate XML file defining a custom background for the dashboard. This custom background utilizes a rectangular shape with rounded corners, creating a sleek and modern appearance. The use of a solid color with a gradient effect enhances the visual appeal of the dashboard, making it more eye-catching and aesthetically pleasing.
Functionalities and Interactivity: The Java code provided demonstrates how to implement functionality for each CardView element in the dashboard. Upon clicking each section, a corresponding message is displayed using a Toast, ensuring that users receive feedback when interacting with different parts of the dashboard. This interactive feature enhances the usability of the dashboard, making it more engaging and user-centric.
By following this tutorial, you can easily create a modern and visually appealing dashboard UI in your Android app. The use of CardView and custom background styling allows you to design a sleek and intuitive interface, while the interactive functionalities ensure a user-friendly and engaging experience. Whether you’re developing a productivity app, a social platform, or any other type of Android application, implementing a modern dashboard UI can significantly enhance the overall user experience and make your app stand out in the competitive market.