16
Новинки в support-library Ждут своего часа. Гончаров Степан Android Developer

Новинки в support-library

Embed Size (px)

DESCRIPTION

Новинки в support-library

Citation preview

Page 1: Новинки в support-library

Новинки в support-libraryЖдут своего часа.

Гончаров СтепанAndroid Developer

Page 2: Новинки в support-library

Android L

RecyclerViewCardView

Palette

Page 3: Новинки в support-library

ИспользованиеAndroid Studio 0.8+, support lib 21.0.0rc1

compile 'com.android.support:cardview-v7:+'compile 'com.android.support:recyclerview-v7:+'compile 'com.android.support:palette-v7:+'

Page 4: Новинки в support-library

(Не)только для L

v7 || minSdkVersion 'L'

Page 5: Новинки в support-library

И так сойдет

New Manifest Merger

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

<uses-sdk tools:node="replace" />

Page 6: Новинки в support-library

Можно начинатьRecycler View

Layout Manager

Items Animator

Adapter Data set

Page 7: Новинки в support-library

В чем разница?

ListView <= RecyclerView + LinearLayoutManager

HORISONTAL || VERTICAL

Page 8: Новинки в support-library

В чем проблема?AdapterLinearLayoutManagerDefaultAnimator…PROFIT

Page 9: Новинки в support-library

Cursor Adapter @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(itemLayout, parent, false); return new ViewHolder(v, textViewId); } @Override public void onBindViewHolder(ViewHolder holder, int position) { if (cursor == null) return; cursor.moveToPosition(position); holder.text.setText(cursor.getString(columnIndex)); holder.itemView.setOnClickListener(this); }

Page 10: Новинки в support-library

View Holder public static class ViewHolder extends RecyclerView.ViewHolder { public TextView text;

public ViewHolder(View itemView, int textViewId) { super(itemView); itemView.setTag(this); text = (TextView) itemView.findViewById(textViewId); } }

Page 11: Новинки в support-library

Card View<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" card_view:cardCornerRadius="4dp" card_view:cardBackgroundColor="#ffffff" android:foreground="?android:attr/selectableItemBackground">

Page 12: Новинки в support-library
Page 13: Новинки в support-library

Palette

Page 14: Новинки в support-library

6 цветов хватит всем

Vibrant(Normal, Light, Dark)

Muted(Normal, Light, Dark)

Page 15: Новинки в support-library

Где взять?BitmapDrawable bitmapDrawable = (BitmapDrawable) getWallpaper();Palette palette = Palette.generate(bitmapDrawable.getBitmap());

palette.getLightVibrantColor().getRgb();palette.getDarkMutedColor().getHsl();

palette.getPallete();

Page 16: Новинки в support-library

Спасибо за внимание!Demo проект ищите здесь:https://github.com/stepango/support_library_21_demo