Blog purpose for android basic example for android app developer. any query please my contact

Wednesday 8 April 2020

dashboard design in android studio using cardview tutorial



In this article, today learn dashboard design in an android studio using card view tutorial. android can be using a dashboard to create a different type to be an android dashboard example.



Create a new project in Android Studio File–>New–>New Project.
Enter Application Name, Package Name, Select Empty Activity and click on finish.

Dashboard style automaton Studio is the main attraction of any mobile app. It ought to be enticing moreover as user friendly additionally. during this tutorial, I'm progressing to show however you'll be able to build a dashboard that is clean and user friendly.


follow the dashboard design in android studio using cardview tutorial source code:

1. build.gradle:


apply plugin: 'com.android.application'


android {
compileSdkVersion 28
defaultConfig {
applicationId "com.akash.dashboard"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.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'
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'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
}






2 .colors.xml:


<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="green">#00bfa5</color>
<color name="lightgray">#808080</color>
<color name="purple">#7c4dff</color>
<color name="yellow">#ffb300</color>
<color name="pinky">#fe104d</color>
<color name="darkblue">#2980b9</color>
<color name="darkpurple">#a569bd</color>
</resources>








3.dimens.xml:


<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>




4.MainActivity.java:


package com.akash.dashboard;


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


public class MainActivity extends AppCompatActivity {
private ImageView btna,btnb,btnc,btnd,btne,btnf;
final Intent[] intent = new Intent[1];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btna=(ImageView)findViewById(R.id.btna);
btnb=(ImageView)findViewById(R.id.btnb);
btnc=(ImageView)findViewById(R.id.btnc);
btnd=(ImageView)findViewById(R.id.btnd);
btne=(ImageView)findViewById(R.id.btne);
btnf=(ImageView)findViewById(R.id.btnf);


btna.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {


Toast.makeText(MainActivity.this,"You Can Select A",Toast.LENGTH_SHORT).show();


}
});


btnb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {


Toast.makeText(MainActivity.this,"You Can Select B",Toast.LENGTH_SHORT).show();
}
});


btnc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"You Can Select C",Toast.LENGTH_SHORT).show();


}
});




btnd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {


Toast.makeText(MainActivity.this,"You Can Select D",Toast.LENGTH_SHORT).show();


}
});


btne.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"You Can Select E",Toast.LENGTH_SHORT).show();
}
});


btnf.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {


Toast.makeText(MainActivity.this,"You Can Select F",Toast.LENGTH_SHORT).show();
}
});




}
}




5.activity_main.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"
android:padding="22dp"
android:background="#FCFCFC">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<TextView
android:layout_width="329dp"
android:layout_height="wrap_content"
android:text="Dashboard"
android:textAlignment="center"
android:textSize="20dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="25dp">


<android.support.v7.widget.CardView
android:id="@+id/bankcardId"
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
android:padding="0dp">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:background="@color/yellow"
android:gravity="center">


<ImageView
android:id="@+id/btna"
android:layout_width="160dp"
android:layout_height="102dp"
android:padding="10dp"
android:src="@drawable/ic_launcher" />
</LinearLayout>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textColor="#000"
android:textSize="18dp" />


<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="2dp"
android:background="@color/lightgray" />


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A"
android:textColor="@android:color/darker_gray" />


</LinearLayout>
</android.support.v7.widget.CardView>


<android.support.v7.widget.CardView
android:id="@+id/btnb"
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
android:padding="0dp">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:background="@color/yellow"
android:gravity="center">


<ImageView
android:id="@+id/btnb"
android:layout_width="144dp"
android:layout_height="94dp"
android:padding="10dp"
android:src="@drawable/ic_launcher" />
</LinearLayout>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B"
android:textColor="#000"
android:textSize="18dp" />


<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="2dp"
android:background="@color/lightgray" />


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B"
android:textColor="@android:color/darker_gray" />


</LinearLayout>
</android.support.v7.widget.CardView>


</LinearLayout>
<LinearLayout
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:id="@+id/bankcardId2"
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:padding="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:gravity="center"
android:background="@color/yellow">


<ImageView
android:id="@+id/btnc"
android:layout_width="110dp"
android:layout_height="104dp"
android:padding="10dp"
android:src="@drawable/ic_launcher" />
</LinearLayout>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C"
android:textColor="#000"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/lightgray"
android:layout_margin="2dp"/>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C"
android:textColor="@android:color/darker_gray" />


</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:id="@+id/bankcardId3"
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:padding="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:gravity="center"
android:background="@color/yellow">


<ImageView
android:id="@+id/btnd"
android:layout_width="119dp"
android:layout_height="114dp"
android:background="@drawable/ic_launcher"
android:padding="10dp" />
</LinearLayout>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="D"
android:textColor="#000"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/lightgray"
android:layout_margin="2dp"/>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="D"
android:textColor="@android:color/darker_gray" />


</LinearLayout>
</android.support.v7.widget.CardView>


</LinearLayout>
<LinearLayout
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:id="@+id/bankcardId5"
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:padding="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:gravity="center"
android:background="@color/yellow">


<ImageView


android:id="@+id/btne"
android:layout_width="64dp"
android:layout_height="64dp"
android:padding="10dp"
android:src="@drawable/ic_launcher" />
</LinearLayout>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="F"
android:textColor="#000"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/lightgray"
android:layout_margin="2dp"/>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="F"
android:textColor="@android:color/darker_gray" />


</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:id="@+id/bankcardId4"
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:padding="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:gravity="center"
android:background="@color/yellow">


<ImageView
android:id="@+id/btnf"
android:layout_width="64dp"
android:layout_height="64dp"
android:padding="10dp"
android:src="@drawable/ic_launcher" />
</LinearLayout>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="G"
android:textColor="#000"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/lightgray"
android:layout_margin="2dp"/>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="G"
android:textColor="@android:color/darker_gray" />


</LinearLayout>
</android.support.v7.widget.CardView>


</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>






6.AndroidManifest.xml:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.akash.dashboard">


<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />


<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>


</manifest>









No comments:

Post a Comment