Friday, 24 June 2016

HOME MATERIAL DESIGN

Android Getting Started with Material Design 



You may have known about android Material Design which was presented in Android Lollipop rendition. In Material Design parcel of new things were presented like Material Theme, new gadgets, custom shadows, vector drawables and custom activitys. On the off chance that you haven't taking a shot at Material Design yet, this article will give you a decent begin.

In this instructional exercise we are going to take in the fundamental strides of Material Design advancement i.e composing the custom subject and executing the route drawer utilizing the RecyclerView.

Experience the beneath connections to get more learning over Material Design.

> Material Design Specifications

> Creating Apps with Material Design

DOWNLOAD CODE

VIDEO DEMO



1. Downloading Android Studio

Before going further, download the Android Studio and do the essential setup as I am going to utilize Android Studio for all my instructional exercise starting now and into the foreseeable future. On the off chance that you are attempting the Android Studio surprisingly, go the diagram doc to get complete review of android studio.



2. Material Design Color Customization

Material Design gives set of properties to redo the Material Design Color subject. In any case, we utilize five essential ascribes to tweak general subject.

colorPrimaryDark – This is darkest essential shade of the application mostly applies to notice bar foundation.

colorPrimary – This is the essential shade of the application. This shading will be connected as toolbar foundation.

textColorPrimary – This is the essential shade of content. This applies to toolbar title.

windowBackground – This is the default foundation shade of the application.

navigationBarColor – This shading characterizes the foundation shade of footer route bar.

android-material-plan shading mapping

You can experience this material outline shading designs and pick the one that suits your application.




3. Making Material Design Theme

1. In Android Studio, go to File ⇒ New Project and fill all the points of interest required to make another undertaking. When it prompts to choose a default action, select Blank Activity and continue.

2. Open res ⇒ values ⇒ strings.xml and include underneath string values.

strings.xml



Material Design

Settings

Search

Open

Close

Home

Friends

Messages

<!- - route drawer thing names - >



@string/nav_item_home

@string/nav_item_friends

@string/nav_item_notifications


Messages

Friends

Home






3. Open res ⇒ values ⇒ colors.xml and include the beneath shading values. On the off chance that you don't discover colors.xml, make another asset record with the name.

colors.xml





#F50057

#C51162

#FFFFFF

#FFFFFF

#000000

#FF80AB





4. Open res ⇒ values ⇒ dimens.xml and include beneath measurements.

dimens.xml



<!- - Default screen edges, per the Android Design rules. - >

16dp

16dp

260dp






5. Open styles.xml under res ⇒ values and include beneath styles. The styles characterized in this styles.xml are regular to all the android forms. Here I am naming my topic as MyMaterialTheme.

styles.xml












6. Presently under res, make an envelope named values-v21. Inside qualities v21, make another styles.xml with the beneath styles. These styles are particular to Android Lollipop as it were.

styles.xml










7. Presently we have the fundamental Material Design styles prepared. With a specific end goal to apply the topic, open AndroidManifest.xml and alter the android:theme characteristic of tag. 

android:theme="@style/MyMaterialTheme"

So in the wake of applying the subject, your AndroidManifest.xml ought to look like underneath.

AndroidManifest.xml




package="info.androidhive.materialdesign" >


android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:theme="@style/MyMaterialTheme" >


android:name=".activity.MainActivity"

android:label="@string/app_name" >















Presently in the event that you run the application, you can see the notice bar shading changed to the shading that we have said in our styles.

android-material-plan notice bar

3.1 Adding the Toolbar (Action Bar)






8. Make a xml document named toolbar.xml under res ⇒ format and include android.support.v7.widget.Toolbar component. This make the toolbar with particular tallness and theming.

toolbar.xml




xmlns:local="http://schemas.android.com/apk/res-auto"

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:minHeight="?attr/actionBarSize"

android:background="?attr/colorPrimary"

local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

local:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>




9. Open the format record of your principle movement (activity_main.xml) and include the toolbar utilizing tag. 

activity_main.xml


xmlns:tools="http://schemas.android.com/apparatuses"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">


android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_alignParentTop="true"

android:orientation="vertical">


android:id="@+id/toolbar"

layout="@layout/toolbar"/>





Run the application and check whether the toolbar showed on the screen or not.

android-material-plan toolbar

Presently we should attempt to include a toolbar title and empower the activity things.




10. Download this inquiry symbol and import it into Android Studio as an Image Asset.




11. To import the Image Asset in Android Studio, right tap on res ⇒ New ⇒ Image Asset. It will demonstrate to you a popup window to import the asset. Skim the hunt symbol that you have downloaded in the above stride, select Action Bar and Tab Icons for Asset Type and give the asset name as ic_search_action and continue.

android-studio-importing-picture resource



12. Once the symbol is foreign, open menu_main.xml situated under res ⇒ menu and include the inquiry menu thing as specified underneath.

menu_main.xml


xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/devices"

tools:context=".MainActivity">


android:id="@+id/action_search"

android:title="@string/action_search"

android:orderInCategory="100"

android:icon="@drawable/ic_action_search"

app:showAsAction="ifRoom"/>


android:id="@+id/action_settings"

android:title="@string/action_settings"

android:orderInCategory="100"

app:showAsAction="never"/>





13. Presently open your MainActivity.java and do the beneath changes.

> Extend the action from AppCompatActivity

> Enable the toolbar by calling setSupportActionBar() by passing the toolbar object.

> Override onCreateOptionsMenu() and onOptionsItemSelected() strategies to empower toolbar activity i

No comments:

Post a Comment