如何最大限度地减少Android上的卡片?

时间:2015-02-05 11:14:56

标签: android wear-os android-wear-notification

我已经通过参考以下教程https://developer.android.com/training/wearables/ui/cards.html

成功地在android服装上创建了一张示例卡

但我的样本卡在向下滑动时不会最小化。

这是我得到的输出

Only right swipe will work(to dismiss card)

我想要这样的事情

Normal stage of wear app running

当我向下滑动卡时,这样会最小化 minimized state

就像播放可穿戴设备的媒体播放器应用一样!

任何人都可以帮我吗?我刚刚开始学习可穿戴设备的开发。

这是我的代码

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>

1 个答案:

答案 0 :(得分:1)

我认为您要找的是通知:https://developer.android.com/training/wearables/notifications/creating.html

通知会在最小化时显示标题,当您向上滑动时会显示全文或自定义布局(https://developer.android.com/training/wearables/apps/layouts.html)。