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

问题描述 投票:0回答:1

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

clock icon

android real-time android-icons adaptive-icon
1个回答
0
投票

您必须创建一个小部件应用程序才能做到这一点,

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#文档添加小部件

© www.soinside.com 2019 - 2024. All rights reserved.