Chr*_*vik 1 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...
Run Code Online (Sandbox Code Playgroud)
我的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:+'
}
Run Code Online (Sandbox Code Playgroud)
我真的不知道如何解决这个错误,我已经尝试清理项目并重新安装应用程序,但错误仍然存在.有人成功使用过这些布局吗?
https://developer.android.com/training/wearables/apps/layouts.html
系统找不到这样的类,android.view.CardScrollView因为..没有这样的类.根据可穿戴支持文档,它CardScrollView是在android.support.wearable.view包中而不是在包中android.view.
您需要输入android.support.wearable.view.CardScrollView才能使用此视图.
您可以使用以下方法之一为通知中的自定义内容提供高度:
或
setCustomContentHeight(int height)
setCustomSizePreset(int sizePreset)
有了setCustomContentHeight你只需要指定像素大小,但在setCustomSizePreset您需要使用预定义的预设之一:
WearableExtender.SIZE_DEFAULTWearableExtender.SIZE_FULL_SCREENWearableExtender.SIZE_LARGEWearableExtender.SIZE_MEDIUMWearableExtender.SIZE_SMALLWearableExtender.SIZE_XSMALLBTW.我怀疑你可以在自定义卡片布局中使用可滚动的布局.
| 归档时间: |
|
| 查看次数: |
1517 次 |
| 最近记录: |