• Stars
    star
    165
  • Rank 222,018 (Top 5 %)
  • Language
    Java
  • Created almost 10 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This project is focused on the sample using the API's new preview version of Android-L, use of transitions, shadows etc...

Android L preview example

Description

This project is focused on the sample using the API's new preview version of Android-L, use of transitions, shadows etc...,

Alt text

UI

This app is aimed to use the new Material Design released at the Google I/0 14, to use the Material theme on your app, you only have to set the parent of your app style to @android:style/Theme.Material or @android:style/Theme.Material.Light and @android:style/Theme.Material.DarkActionBar.

Customize the Color Palette of your app

In the theme.xml of the MainActivity:

    <!-- App colors -->
    <color name="lollipop_theme_default_primary">#3F51B5</color>
    <color name="lollipop_theme_default_primary_dark">#303F9F</color>
    <color name="lollipop_theme_default_accent">#C5CAE9</color>
    <color name="fab_color">#FF4081</color>


    <!-- Main theme colors -->
    <style name="MainLollipopTheme" parent="android:Theme.Material.Light">
        <item name="android:colorPrimary">@color/lollipop_theme_default_primary</item>
        <item name="android:colorPrimaryDark">@color/lollipop_theme_default_primary</item>
        <item name="android:statusBarColor">@color/lollipop_theme_default_primary_dark</item>
        <item name="android:colorAccent">@color/lollipop_theme_default_accent</item>
        <item name="android:colorControlHighlight">@color/lollipop_theme_default_accent</item>
        <item name="android:navigationBarColor">@color/lollipop_theme_default_primary</item>

        <!-- Main theme action bar-->
        <item name="android:actionBarStyle">@style/MainActionBar</item>
        <item name="android:actionBarTheme">@style/MainActionBarThemeOverlay</item>


        <!-- lag indicating whether this window requests that content changes be performed
             as scene changes with transitions -->
        <item name="android:windowContentTransitions">true</item>

        <!-- Flag indicating whether this Window's transition should overlap with
             the exiting transition of the calling Activity. -->
        <item name="android:windowAllowEnterTransitionOverlap">true</item>

        <!--Flag indicating whether this Window's transition should overlap with
             the exiting transition of the called Activity when the called Activity
             finishes. -->
        <item name="android:windowAllowExitTransitionOverlap">true</item>

        <!-- Flag indicating whether this window's Action Bar should overlay -->
        <item name="android:windowActionBarOverlay">false</item>

        <!-- Flag indicating whether this window's Action Bar content should overlay -->
        <item name="android:windowContentOverlay">@null</item>
    </style>

Customizing the material theme <- This easy picture on Android Developers explains where are the attributes that of the previous code.

The FAB Button

Android-L introduces a new way to manage view with elevation and shadows, "Outlines represent the outer shape of a graphics object and define the ripple area for touch feedback." Android Developers, the fab button is defined as a ImageButton in the xml:

...
    <!-- fab button -->
    <ImageButton
        android:id="@+id/fab"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_width="@dimen/fab_size"
        android:layout_height="@dimen/fab_size"
        android:layout_gravity="bottom|right"
        android:layout_marginRight="16dp"
        android:layout_marginBottom="16dp"
        android:background="@drawable/fab_ripple"
        android:elevation="@dimen/button_elevation"
        android:onClick="onFabClicked"
        android:src="@drawable/ic_action_add"/>
...
        // Configure the FAB button
        int size = getResources().getDimensionPixelSize(R.dimen.fab_size);
        Outline outline = new Outline();
        outline.setOval(0, 0, size, size);
        findViewById(R.id.fab).setOutline(outline);

Activity transitions

Now, with Android-L you can specify custom animations for enter and exit transitions, and for transition of shared elements between activities, to do that, first, you have to enable the window content transitions, in my case, at themes.xml you can set this values from java code as well.

    <style name="MainLollipopTheme" parent="android:Theme.Material.Light">
        ...
        <!-- lag indicating whether this window requests that content changes be performed
       as scene changes with transitions -->
        <item name="android:windowContentTransitions">true</item>

        <!-- Flag indicating whether this Window's transition should overlap with
             the exiting transition of the calling Activity. -->
        <item name="android:windowAllowEnterTransitionOverlap">true</item>

        <!--Flag indicating whether this Window's transition should overlap with
             the exiting transition of the called Activity when the called Activity
             finishes. -->
        <item name="android:windowAllowExitTransitionOverlap">true</item>

        <!-- Flag indicating whether this window's Action Bar should overlay -->
        <item name="android:windowActionBarOverlay">false</item>

        <!-- Flag indicating whether this window's Action Bar content should overlay -->
        <item name="android:windowContentOverlay">@null</item>
        ...
    </style>
    
        // Setup the transition to the detail activity
        ActivityOptions options =  ActivityOptions.makeSceneTransitionAnimation(MainActivity.this, view, "photo" + i);
        startActivity(detailIntent, options.toBundle());

Tools & References:

More Repositories

1

Android-Material-Examples

[Deprecated] Little bites of Material Design
Java
2,835
star
2

CoordinatorBehaviorExample

Java
2,718
star
3

Material-Movies

[Deprecated] An application about movies with material design
Java
2,436
star
4

CoordinatorExamples

Different CoordinatorLayout usages, tips & examples
Java
1,323
star
5

Curved-Fab-Reveal-Example

Java
1,151
star
6

Avengers

[Deprecated] This project aims to work as a demo project and reference using the common frameworks and tools
Java
1,083
star
7

From-design-to-Android-part1

First part of 'from design to android' series
Java
626
star
8

onboarding-examples-android

Java
578
star
9

From-design-to-Android-part2

Kotlin
429
star
10

OpenLibra-Material

OpenLibra client on Material Design
Java
359
star
11

Android-Notification-Example

A simple sample showing the different types of notifications on Andoid
Shell
191
star
12

Gradle-Stuff

Java
59
star
13

RecyclerView-demo

Java
56
star
14

android_sign_in_sample

Java
30
star
15

twitter-for-android-wear

Java
26
star
16

android-refresh-layout-example

Java
24
star
17

android_tts_example

A simple android app showing an implementation of android sdk tts system
Java
22
star
18

android-arrow-drawable-sample

Java
16
star
19

Android-Wearable-example

Java
10
star
20

Retrofit-2-basic-sample

Basic usage of Retrofit 2 (Beta stage)
Java
8
star
21

Precompiled-Scripts-With-Version-Catalogs

Kotlin
7
star
22

android-wear-basics

Java
6
star
23

Android-Dagger-Example

Java
4
star
24

twitter-for-galaxy-gear

Java
4
star
25

myAwesomeSpaceJavaGame

A simple space java game :)
Java
4
star
26

dagger2-sample

Java
4
star
27

Letters

Under construction :P
Java
2
star
28

android_gdg_vigo_app

Java
2
star
29

codewars

Kotlin
2
star
30

Airport-management

C
1
star
31

android-api-loquacious

Loquacious is a localized remote resource manager library for Android
Kotlin
1
star