Thursday, October 15, 2015

Using android.support.design in android

Android Design Support Library

With a little help from the new Android Design Support Library, Google bringing a number of important material design components to all developers and to all Android 2.1 or higher devices. You’ll find a navigation drawer view, floating labels for editing text, a floating action button, snackbar, tabs, and a motion and scroll framework to tie them together.



 With help of this,you can make your designs more interactive and good.


 Following examples shows usage of
1.Coordinator Layout
2.AppBarLayout
3.Collapsing Layout
4.TextInputLayout.
5.ToolBar.
6.Nested Scroll View
7.FloatingActionButton (FAB)


XML (Layout) demonstrating  android.support.design usage :

<android.support.design.widget.CoordinatorLayout 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:orientation="vertical"
                                                 tools:context="car.sharewhere.gagan.sharewherecars.fragments.Find_A_Ride">


    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:titleEnabled="false"
            >

            <LinearLayout
                android:layout_marginTop="30dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="20dp">

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        >

                        <AutoCompleteTextView
                            android:id="@+id/autocompleteFrom"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="Leaving from"
                            android:singleLine="true"/>

                    </android.support.design.widget.TextInputLayout>


                    <ImageButton

                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:background="@null"
                        android:src="@android:drawable/presence_online"
                        android:visibility="gone"/>


                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="20dp"
                    android:layout_marginBottom="5dp">

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1">

                        <AutoCompleteTextView
                            android:id="@+id/autocompleteTo"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="Going to"
                            android:singleLine="true"/>


                    </android.support.design.widget.TextInputLayout>

                </LinearLayout>

            </LinearLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="pin" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    <ListView
        android:id="@+id/listVFindRide"
        android:layout_width="match_parent"
        android:layout_height="match_parent"> </ListView>
        </LinearLayout>
</android.support.v4.widget.NestedScrollView>


    <android.support.design.widget.FloatingActionButton
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        app:layout_anchor="@id/appbar"
        app:backgroundTint="@color/white"
        app:layout_anchorGravity="bottom|right|end"
        android:src="@android:drawable/ic_search_category_default"
        android:layout_margin="@dimen/fab_margin"
        android:clickable="true"/>

</android.support.design.widget.CoordinatorLayout>

0 comments:

Post a Comment

Don't lose faith when you see others receive answers to their prayers

An elephant and a dog became pregnant at same time. Three months down the line the dog gave birth to six puppies. Six months later the dog...

 

G-Expo Template by Ipietoon Cute Blog Design