Android L preview example
来源:互联网 发布:Windows匿名用户 编辑:程序博客网 时间:2024/05/18 03:36
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...,
UI
This app is aimed to use the new Material Design released at the Google I/0 14, to use theMaterial
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 onAndroid 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());原文出自IT蓝豹:http://www.itlanbao.com,请转载时明标注出处,谢谢!
- Android L preview example
- Android L Developer Preview
- Android L Preview Root教程
- Android L Preview 源码同步方法
- The project target (Android L (Preview)) was not properly loaded.
- Android L Developer Preview:安卓最新测试版发布
- Android L-preview PackageManagerService启动、安装和卸载分析
- The project target (Android L (Preview)) was not properly loaded.
- 蓝牙广播数据 Android L Preview 当前效果
- The project target (Android L (Preview)) was not properly loaded.
- Running Android L Developer Preview on 64-bit ARM QEMU
- 升级Android L完后,打开项目出现'load data for Android L(preview)'has encountered a problem.
- Android L Preview for mako本人编译版的启动log
- 【Android Camera】之 Preview
- 【Android Camera】之 Preview
- 【Android Camera】之 Preview
- 【Android Camera】之 Preview
- 【Android Camera】之 Preview
- 随诊医生2---检查版本更新
- Shadow Defender 1.4.0.561 简体中文注册码破解版(最好用的影子保护系统)
- java小例子实现死锁
- Xcode7 总结
- java基本名词
- Android L preview example
- 自同步 ZiSync For Windows 1.3 最新测试版(最好用的局域网同步软件)
- HADOOP基本操作命令
- testing
- 编译Room之各项操作
- OC学习Runtime之协议与分类
- 浅谈协方差矩阵
- 【springmvc+mybatis项目实战】杰信商贸-24.神奇的POI
- Html5 Api 实现浏览器全屏