Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何在主屏幕小部件中包含CardView大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试构建一个具有多个时钟(不同区域)的简单主屏幕小部件.设计方面,我想使用CardView(例如谷歌搜索栏)作为根布局元素,但由于小部件不支持,我该如何复制它?我可以以某种方式使用其父类,即帧布局吗?

解决方法

您可以使用受支持的视图类并将背景drawable设置为此处定义的card_drawable:

https://gist.github.com/MarsVard/8297976

例如,对于LinearLayout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://scheR_743_11845@as.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:padding="8dp"
              >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:BACkground="@drawable/card_drawable"
        >
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Test"
            />
        </LinearLayout>
</LinearLayout>

大佬总结

以上是大佬教程为你收集整理的android – 如何在主屏幕小部件中包含CardView全部内容,希望文章能够帮你解决android – 如何在主屏幕小部件中包含CardView所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。