Upgrade to Pro — share decks privately, control downloads, hide ads and more …

"Android Niceties" from David Mayboroda

"Android Niceties" from David Mayboroda

Nowadays the beauty of apps plays an importance from very beginning, especially as programmers motivation to make apps attractive. Design is important, with both ui and code. David’s topic will be an adapter from design cuties to code grace.

uaMobiTech

July 28, 2016
Tweet

More Decks by uaMobiTech

Other Decks in Programming

Transcript

  1. <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/style_color_primary</item> <item name="colorPrimaryDark">@color/style_color_primary_dark</item> <item name="colorAccent">@color/style_color_accent</item> <item

    name="colorControlHighlight">@color/fab_color_pressed</item> </style> <style name="AppTheme.TransparentActivity"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowIsTranslucent">true</item> </style> <style name="AppTheme.TransparentActivity.FullScreen"> <item name="android:windowFullscreen">true</item> </style>
  2. <RelativeLayout> <android.support.design.widget.CoordinatorLayou> <android.support.v7.widget.RecyclerView app:layout_behavior="@string/appbar_scrolling_view_behavior" /> <android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout> <android.support.v7.widget.Toolbar app:elevation="@dimen/default_elevation" app:layout_scrollFlags=“scroll|enterAlways"

    app:theme=“@style/ThemeOverlay.AppCompat.Dark.ActionBar” > <ImageView> </android.support.v7.widget.Toolbar> <android.support.design.widget.FloatingActionButton android:layout_gravity="bottom|right" app:borderWidth="0dp" app:elevation="6dp" app:pressedTranslationZ="12dp" /> </android.support.design.widget.CoordinatorLayout> </RelativeLayout>
  3. <merge > </merge> <Button android:id=“@+id/share”/> <Button android:id=“@+id/copy”/> <Button android:id=“@+id/cancel”/> public

    class FeedContextMenu extends LinearLayout { public FeedContextMenu(Context context) { super(context); LayoutInflater.from(context).inflate(R.layout.view_context_menu, this, true); setBackgroundResource(R.drawable.bg_container_shadow); setOrientation(VERTICAL); setLayoutParams(new LayoutParams(CONTEXT_MENU_WIDTH, ViewGroup.LayoutParams.WRAP_CONTENT)); } @Override protected void onFinishInflate() { super.onFinishInflate(); ButterKnife.bind(this); } }
  4. contextMenuView.getViewTreeObserver().addOnPreDrawListener( new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { contextMenuView.getViewTreeObserver()

    .removeOnPreDrawListener(this); setupContextMenuInitialPosition(openingView); performShowAnimation(); return false; } }); private void setupContextMenuInitialPosition(View openingView) { final int[] openingLocation = new int[2]; int width = contextMenuView.getWidth(); int height = contextMenuView.getHeight(); openingView.getLocationOnScreen(openingLocation); contextMenuView.setTranslationX(openingLocation[0] - width/ 3); contextMenuView.setTranslationY(openingLocation[1] - height); }
  5. private void performShowAnimation() { contextMenuView.setPivotX(contextMenuView.getWidth() / 2); contextMenuView.setPivotY(contextMenuView.getHeight()); contextMenuView.setScaleX(0.1f); contextMenuView.setScaleY(0.1f);

    contextMenuView.animate() .scaleX(1f).scaleY(1f) .setDuration(150) .setInterpolator(new OvershootInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { … } }); }