java.lang.ClassNotFoundException:没有找到类“android.view.CardScrollView”

时间:2014-08-22 12:38:04

标签: android-notifications wear-os

我正在尝试构建我的自定义通知,但我的一切正常,但我的布局在流卡中被切断了。似乎它设法在流卡中显示我的整个自定义布局,即使我只使用大约50%的屏幕高度。但我看到其他自定义布局,例如Google Now的体育卡比我的大。

所以我尝试将我的RelativeLayout包装在CardScrollView中(不确定它会有帮助)但是当我运行该代码时,Wear设备崩溃了:

java.lang.RuntimeException: Unable to start activity ComponentInfo ...

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.CardScrollView" on path: DexPathList[[zip file "/data/app/com.myapp.apk"],nativeLibrary...

我的gradle文件如下所示:

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 compile project(':common')
 compile 'com.google.android.support:wearable:+'
 compile 'com.google.android.gms:play-services-wearable:+'
}

我真的不知道如何修复此错误,我已经尝试清理项目并重新安装应用程序,但错误仍然存​​在。有人成功使用过这些布局吗?

https://developer.android.com/training/wearables/apps/layouts.html

1 个答案:

答案 0 :(得分:5)

CardScrollView:

系统无法找到像android.view.CardScrollView这样的类,因为..没有这样的类。 根据可穿戴支持文档,CardScrollView位于android.support.wearable.view包中,而不在android.view中。

您需要输入android.support.wearable.view.CardScrollView才能使用此视图。

自定义内容高度:

您可以使用以下方法之一为通知中的自定义内容提供高度:
setCustomContentHeight(int height)

setCustomSizePreset(int sizePreset)

使用setCustomContentHeight,您只需指定大小(以像素为单位),但在setCustomSizePreset中您需要使用其中一个预定义的预设:

顺便说一句。我怀疑你可以在自定义卡片布局中使用可滚动的布局。

相关问题