How to minimize cards on android wear?

I successfully created a map sample on android wear by referring to the following tutorial https://developer.android.com/training/wearables/ui/cards.html

But my sample map does not collapse down.

This is the result that I get

Only right swipe will work (to dismiss card)

I want something like this

Normal stage of wear app running

and when I scroll the map it will be minimized minimized state

Just like a wearable media player app!

Can anyone help me with this? I just started to learn how to wear it.

Here is my code

package com.example.cardsample; import android.app.Activity; import android.os.Bundle; import android.support.wearable.view.CardScrollView; import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.rect); CardScrollView cardScrollView = (CardScrollView) findViewById(R.id.card_scroll_view); cardScrollView.setCardGravity(Gravity.BOTTOM); } } 

rect.xml

 <android.support.wearable.view.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@drawable/ic_full_sad" android:layout_height="match_parent" android:layout_width="match_parent"> <android.support.wearable.view.CardScrollView android:id="@+id/card_scroll_view" android:layout_height="match_parent" android:layout_width="match_parent" app:layout_box="bottom"> <android.support.wearable.view.CardFrame android:layout_height="wrap_content" android:layout_width="fill_parent"> <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="vertical" android:paddingLeft="5dp"> <TextView android:fontFamily="sans-serif-light" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="Heading" android:textColor="@color/black" android:textSize="20sp"/> <TextView android:fontFamily="sans-serif-light" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="description" android:textColor="@color/black" android:textSize="14sp"/> </LinearLayout> </android.support.wearable.view.CardFrame> </android.support.wearable.view.CardScrollView> </android.support.wearable.view.BoxInsetLayout> 
+6
source share
1 answer

I think you are looking for a notification: https://developer.android.com/training/wearables/notifications/creating.html

The notification shows the title when it is minimized, and when it scrolls, the full text or your own layout is displayed ( https://developer.android.com/training/wearables/apps/layouts.html ).

+1
source

Source: https://habr.com/ru/post/982037/


All Articles