Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to minimize cards on android wear?

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

But my sample card doesn't minimize on down swipe.

This is the output I'm getting

Only right swipe will work(to dismiss card)

I want some thing like this

Normal stage of wear app running

and when I swipe down card will minimize like this minimized state

Just like media player app working on wearable!

Can anyone help me with this? I have just started learning development for wearable.

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>
like image 520
san Avatar asked Feb 05 '15 11:02

san


People also ask

What is card in android?

CardView is a new widget in Android that can be used to display any sort of data by providing a rounded corner layout along with a specific elevation. CardView is the view that can display views on top of each other. The main usage of CardView is that it helps to give a rich feel and look to the UI design.

What is ambient mode on Android Wear?

Wear OS automatically handles moving into low-power mode for an active app when a user is no longer using their watch. This is called the system ambient mode. If the user interacts with the watch again within a certain time frame, Wear OS brings the user back into the app where they left off.


1 Answers

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

A notification shows the title when its minimized and when you swipe up it shows the full text or your custom layout (https://developer.android.com/training/wearables/apps/layouts.html).

like image 100
jlmd Avatar answered Oct 27 '22 00:10

jlmd