houzhi0608 / NewAppWidget

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New AppWidget in Android 12

New AppWidget demo that used with AppWidget API in Android 12.

📸Screenshot

Rounded corner AppWidget

12-widget

Dynamic color effect

12-widget

Responsive layouts

12-widget

State View AppWidget

12-widget

Simplified RemoteViews collections

CheckBox精准布局预览

Runtime modification of RemoteViews

Change checkbox text color when checked.

12-widget

Change chart's size when tapped.

12-widget

📙 New AppWidget API

RemoteViews类

方法 作用
RemoteViews(Map<SizeF, RemoteViews>) 根据响应式布局映射表创建目标RemoteViews
addStableView() 向RemoteViews动态添加子View,类似ViewGroup#addView()
setCompoundButtonChecked() 针对CheckBox或Switch控件更新选中状态
setRadioGroupChecked() 针对RadioButton控件更新选中状态
setRemoteAdapter(int , RemoteCollectionItems) 直接将数据填充进小组件的ListView
setColorStateList() 动态更新小组件视图的颜色
setViewLayoutMargin() 动态更新小组件视图的边距
setViewLayoutWidth()、setViewLayoutHeight() 动态更新小组件视图的宽高
setOnCheckedChangeResponse() 监听CheckBox等三种状态小部件的状态变化

XML属性

属性 作用
description 配置小组件在选择器里的补充描述
previewLayout 配置小组件的预览布局
reconfigurable 指定小组件的尺寸支持直接调节
configuration_optional 指定小组件的内容可以采用默认设计,无需启动配置画面
targetCellWidth、targetCellHeight 限定小组件所占的Launcher单元格
maxResizeWidth、maxResizeHeight 配置小组件所能支持的最大高宽尺寸

📙 New AppWidget Feature

https://developer.android.google.cn/about/versions/12/features/widgets

📙 My blog

https://blog.csdn.net/allisonchen

©️ License

MIT License

Copyright (c) 2021 Ellison Chan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

License:MIT License


Languages

Language:Kotlin 100.0%