繁体   English   中英

如何在Android中实现像时钟/日历应用程序这样的实时动态图标?

[英]How to implement real time dynamic icon like clock/ calendar app in android?

在android时钟应用程序图标中,正确的模拟实时显示在图标中,即使日历应用程序图标中也显示了今天的日期。 如何在应用程序中实现实时图标?

时钟图标

为此,您必须创建一个小部件应用程序,

https://developer.android.com/guide/topics/appwidgets#

理想情况下,您将与

<activity android:name=".ClockChoice"> 
</activity>

它由您的xml中的模拟时钟组成,例如

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"> 


   <AnalogClock

       android:layout_marginTop="20dp"
       android:layout_marginLeft="120dp"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" /> 


</RelativeLayout> 

然后按照https://developer.android.com/guide/topics/appwidgets#文档添加小部件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM