embracing the lollipop

23
Embracing the Lollipop Sonja Kesic - PSTech

Upload: sonjakesic

Post on 09-Aug-2015

57 views

Category:

Software


0 download

TRANSCRIPT

  1. 1. Embracing the Lollipop Sonja Kesic - PSTech
  2. 2. PSTech We develop core apps on top of Vanilla implementation Lollipop - the greatest update of them all Why am I here?
  3. 3. Define custom colors using theme attributes to brand the application: colorPrimary, colorPrimaryDark, colorAccent Reduced color palette comprised of bold vibrant colors Use opacity for text, icons and dividers @android:style/Theme.Material
  4. 4. http://www.materialpalette.com/
  5. 5. @android:style/Theme.Material Ripple effect as default touch feedback for buttons To apply ripple feedback for other views set view background to ?android:attr/selectableItemBackground Using RippleDrawable from XML:
  6. 6. @android:style/Theme.Material
  7. 7. FAB
  8. 8. FAB example implementation
  9. 9. Cards Display multiple heterogeneous data types (mixed images, text, video...) Its not a replacement for a list or a grid Cards content can be dismissible and user could interact with it (like, comment, etc) FrameLayout android.support.v7.widget.CardView with built-in elevation and rounded corners
  10. 10. Advanced ListView created with flexibility in mind RecyclerView.Adapter is required to supply the data. There is no default implementation for CursorAdapter RecyclerView.ViewHolder enforces the use of view holder Need for supplying layout manager implementation. There is a default implementation of RecyclerView.LayoutManager for both vertical and horizontal linear layout Touch handling: RecyclerView.OnItemTouchListener RecyclerView.ItemAnimator responsible for animations RecyclerView
  11. 11. public class DroidconRecyclerAdapter extends RecyclerView.Adapter { } public class DroidconViewHolder extends RecyclerView.ViewHolder { public TextView text; public DroidconViewHolder(View itemView) { super(itemView); text= itemView.findViewById(R.id.text); } } RecyclerView example
  12. 12. public class DroidconRecyclerAdapter extends RecyclerView.Adapter { @Override public DroidconViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { } @Override public void onBindViewHolder(DroidconViewHolder holder, int position) { } } RecyclerView example
  13. 13. public class DroidconRecyclerAdapter extends RecyclerView.Adapter { @Override public DroidconViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = mInflater.inflate(R.layout.item, parent, false); return new DroidconViewHolder(v); } @Override public void onBindViewHolder(DroidconViewHolder holder, int position) { holder.text.setText(mItems.get(position)); } RecyclerView example
  14. 14. public class DroidconViewHolder extends RecyclerView.ViewHolder { public DroidconViewHolder(View itemView) { super(itemView); itemView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Do something } }); } RecyclerView
  15. 15. recyclerView = (RecyclerView)findViewById(R.id.horizontal_list); recyclerView.setAdapter(new DroidconRecyclerAdapter(mDroidconItems)); recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); recyclerView.setItemAnimator(new DefaultItemAnimator()); RecyclerView
  16. 16. Transition framework since KitKat Key concepts: Scene and Transition Whats new in the API? Support for animations when switching between activities and fragments Shared element animations Activity and Fragment Transitions
  17. 17. Content and shared element transitions
  18. 18. Supported content transitions: Fade, Slide, Explode Howto do it? Setit in thetheme: @transition/explode@transition/explode Requestitin the code: getWindow().setExitTransition(new Explode()); Call correspondingFragment methodsorset it in FragmentXML: ContentTransitions
  19. 19. Supportedcontenttransitions:ChangeBounds, ChangeTransform, ChangeClipBounds, ChangeImageTransform Howtodoit? 1. Specify shared element transition in theme: @transition/image_transform 2. Definetransitionin XML: SharedElement Transitions
  20. 20. 3. Assign a common name for the shared views in both layouts by using android:transitionName attribute. 4. Start the activity with a Bundle holding transitions and shared views: // create the transition animation - the images in the layouts // of both activities are defined with android:transitionName=user_photos" ActivityOptions options = ActivityOptions .makeSceneTransitionAnimation(this, userPhotoView, user_photos"); // start the new activity startActivity(intent, options.toBundle()); 5. To reverse the scene transition animation when you finish the second activity call the finishAfterTransition() SharedElement Transitions
  21. 21. http://www.google.com/design/ http://developer.android.com http://android-developers.blogspot.com Sources