Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Google Now and Google+ card interface

Google Now and Google+ (Android) both make use of a card-like interface.

enter image description here

I was wondering if anyone had any idea how this interface can be replicated on Android.

They both have quite interesting animations for displaying new cards too; any thoughts would be great.

like image 330
HBG Avatar asked Jul 24 '12 22:07

HBG


People also ask

What happened to Google Now cards?

Google Now Cards updated to being the Google feed experience, and has since been updated to being Google Discover. It integrated with the Google Assistant to support Google's role as an answer engine.

What is a Google Now card?

Google Now is a Google mobile app for Android OS that gets users “just the right information at just the right time.” With Google Now, users customize their experience by selecting cards that categorize important information they want to stay up-to-date on, such as music, sports, and local weather.

Why did my Google cards disappear?

If your cards still fail to load, try turning your Google app feed off and on again in the settings. Deleting and reinstalling the Google app may also fix the issue, but you may have to redo some of your feed preferences. Changing your Google preferences can affect your cards.

How do I enable Google cards?

Connect to your WiFi network on your Android device, and tap the Google App. Sign in with your Google account, and you should see a window introducing Google Now, so click “Yes”. Now go to Settings > Google > Search and Now > Now Cards > Now on Tap and enable it if you want Now on Tap cards.


2 Answers

I have posted a tutorial on how to replicate / create Google Cards style layout here.

Key steps

  1. Create a custom layout
  2. Add observer for drawing children
  3. Animate alternating cards

Heres a code snippet

@Override public void onGlobalLayout() {     getViewTreeObserver().removeGlobalOnLayoutListener(this);      final int heightPx = getContext().getResources().getDisplayMetrics().heightPixels;      boolean inversed = false;     final int childCount = getChildCount();      for (int i = 0; i < childCount; i++) {         View child = getChildAt(i);          int[] location = new int[2];          child.getLocationOnScreen(location);          if (location[1] > heightPx) {             break;         }          if (!inversed) {             child.startAnimation(AnimationUtils.loadAnimation(getContext(),                     R.anim.slide_up_left));         } else {             child.startAnimation(AnimationUtils.loadAnimation(getContext(),                     R.anim.slide_up_right));         }          inversed = !inversed;     }  } 
like image 144
Shardul Avatar answered Sep 18 '22 19:09

Shardul


Take a look at http://ryanharter.com/blog/2013/01/31/how-to-make-an-android-card-list/

Copy of the example:

/res/drawable/bg_card.xml:

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">     <item>         <shape android:shape="rectangle"             android:dither="true">              <corners android:radius="2dp"/>              <solid android:color="#ccc" />          </shape>     </item>      <item android:bottom="2dp">         <shape android:shape="rectangle"             android:dither="true">              <corners android:radius="2dp" />              <solid android:color="@android:color/white" />              <padding android:bottom="8dp"                 android:left="8dp"                 android:right="8dp"                 android:top="8dp" />         </shape>     </item> </layer-list> 

Use it as the background of your layout:

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="?android:attr/listPreferredItemHeight"     android:padding="12dp">      <LinearLayout         android:layout_width="match_parent"         android:layout_height="match_parent"          android:layout_marginLeft="6dp"         android:layout_marginRight="6dp"         android:layout_marginTop="4dp"         android:layout_marginBottom="4dp"         android:background="@drawable/bg_card">          <!-- Card Contents go here -->      </LinearLayout>  </FrameLayout> 
like image 36
userM1433372 Avatar answered Sep 20 '22 19:09

userM1433372