android-widget 相关问题

与主屏幕小部件相关,或与Android应用程序屏幕上使用的常规UI元素相关。

创建LinearLayout时出现ArrayIndexOutOfBoundsException

喂?我正在调试一些与 Android 小部件相关的问题。 我的应用程序使用 Glide 库提供的两个线程来制作原始小部件图像文件和缩略图小部件图像文件。 当制作...

回答 1 投票 0

有什么办法可以让点击小部件时不打开应用程序吗?

我正在开发简单的应用程序,该应用程序将在主屏幕上显示小部件,但是当我单击小部件时,我的应用程序每次都会打开。我只需要简单的小部件,它不会打开应用程序或不会在

回答 1 投票 0

Android Studio:使用 RemoteView 设置 ProgressBar 背景颜色

我有这个进度条视图: 我有这个进度条视图: <ProgressBar android:id="@+id/progressBar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent" android:layout_height="6dp" android:layout_centerVertical="true" android:max="100" android:progress="20" android:progressDrawable="@drawable/progress_bar_shape" android:progressTint="#03ff46" // this is the value I'm trying to set via RemoteView android:progressBackgroundTint="#a8a8a8" // also this one /> 我正在尝试使用 RemoteView 设置背景颜色和填充颜色(我将其用于小部件) views.setInt(R.id.progressBar, "setProgressTintList", clockData.getDarkColor()); 我的小部件无法加载,所以这一定是错误的方法。 如何解决这个问题? 谢谢! 您需要在遥控器 setProgressBackgroundTintList() 上拨打 setProgressTintList() 和 View。这两种方法都采用 ColorStateList 作为参数。所以你需要调用 views.setColorStateList() 来做到这一点。看 https://developer.android.com/reference/android/widget/RemoteViews?hl=en#setColorStateList(int,%20java.lang.String,%20android.content.res.ColorStateList)

回答 1 投票 0

Android 小部件上的线程

我正在尝试制作一个小部件时钟。 在我的 MainActivity 上,使用 runOnUiThread 完美显示时钟。 由于小部件不扩展“活动”,我无法 runOnUiThread。 但是当我尝试使用

回答 2 投票 0

防止Android服务被杀死

目前我有一个Android前台服务作为后端,另一个应用程序作为前端。 后端将与硬件通信,前端应用程序供用户控制硬件,后端和

回答 1 投票 0

天文台初始值错误

我编写了一个基于android.widget.Chronometer的简单的国际象棋时钟应用程序。我将它与 setCountDown(true) 标志一起使用,并且所有逻辑都运行良好。每个天文台表都在单独的片段中创建。但是

回答 2 投票 0

这个颤动错误是什么,你能解决吗?

在此输入图像描述 这是我的错误,我无法解决它,请尝试帮助这个错误 在此输入图像描述 /C:/src/flutter/packages/flutter/lib/src/painting/image_provider.dart:814...

回答 1 投票 0

如何设置ListView的最大高度?

我想创建一个 UI,其中屏幕的一半是 ListView,下半部分是另一个视图。不确定如何指定 ListView 的最大高度。 我想创建一个 UI,其中屏幕的一半是 ListView,下半部分是另一个视图。不知道如何指定 ListView 的最大高度。 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Hello StockTwits!"/> <ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/ListView"></ListView><ViewFlipper android:id="@+id/ViewFlipper" android:layout_width="fill_parent" android:layout_height="fill_parent"><LinearLayout android:id="@+id/LinearLayoutST" android:layout_height="fill_parent" android:layout_width="fill_parent"><ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/icon"></ImageView> </LinearLayout> <LinearLayout android:id="@+id/LinearLayoutChart" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TextView android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="View 2"></TextView> </LinearLayout> <LinearLayout android:id="@+id/LinearLayoutDetails" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TextView android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="View 3"></TextView> </LinearLayout> </ViewFlipper> </LinearLayout> 您可以将两个元素的权重设置为 1。这将使它们在屏幕上占据相同的空间量,前提是两者都不需要大于一半。 设置你的父 Linearlayout 权重和为“2” 然后将你的列表视图权重设置为1,并将其他视图权重也设置为1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:weightSum="2" > <ListView android:id="@+id/ListView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" > </ListView><ViewFlipper android:id="@+id/ViewFlipper" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" > <LinearLayout android:id="@+id/LinearLayoutST" android:layout_height="fill_parent" android:layout_width="fill_parent"><ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/icon"></ImageView> </LinearLayout> <LinearLayout android:id="@+id/LinearLayoutChart" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TextView android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="View 2"></TextView> </LinearLayout> <LinearLayout android:id="@+id/LinearLayoutDetails" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TextView android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="View 3"></TextView> </LinearLayout> </ViewFlipper> </LinearLayout> 我已经更改了你的代码,现在试试这个 通过将最大高度设置为 200dp 来解决

回答 3 投票 0

如何以编程方式设置主屏幕小部件上使用的形状的描边颜色

所以,我有这个 rounded_corner_shape.xml 所以,我有这个 rounded_corner_shape.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" > <stroke android:width="1dp" android:color="TO_BE_SET_DYNAMICALLY" /> <corners android:radius="8dp" /> </shape> 用于 ip_properties.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/ip_property_tv_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/rounded_corner_shape" /> </LinearLayout> 然后我想从 RemoteViewsService.RemoteViewsFactory 实现动态设置描边颜色,如下所示: class WifiPropertyViewsFactory: RemoteViewsService.RemoteViewsFactory{ // other overrides... override fun getViewAt(position: Int): RemoteViews = RemoteViews(context.packageName, R.layout.ip_properties) .apply { setTextViewText(R.id.ip_property_tv_1, "some data") // set background rounded corner shape stroke color } } 由于不太了解,我尝试通过RemoteViews.setInt(R.id.ip_property_tv_1, "setBackgroundTint", colorInt)设置,但没有成功。有人知道如何让它发挥作用吗? 尝试此代码 - 文本视图以编程方式更改背景描边颜色 在 setOnClickListener() 方法中使用此代码 edtSelectState.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setStroke(2, Color.RED); edtSelectState.setBackground(gradientDrawable); } });

回答 1 投票 0

创建 Android 智能应用横幅

Android设备有类似iOS 6智能应用横幅的解决方案吗? 这是智能应用横幅的代码 有没有类似iOS 6智能应用横幅的Android设备解决方案? 这是智能应用横幅的代码 <meta name="apple-itunes-app" content="app-id=311507490, affiliate-data=partnerId=30&siteID=k1CkFsOh4nQ"/> 从 Chrome 44 Beta 开始,您可以使用以下命令在 Chrome for Android 中推送您的应用程序 您网站上的本机应用程序安装横幅。 请看下面的答案。 旧答案 我自己需要这个,所以我创建了一个 jquery 插件来模仿 Android 和旧版 iOS 版本的智能横幅。 https://github.com/jasny/jquery.smartbanner 自 Chrome 44 Beta 起,您可以在您的网站上使用本机应用程序安装横幅在 Android 版 Chrome 中推送您的应用程序。为了启用它,需要满足几个标准: 您将需要一个网络应用程序清单文件 您必须使用 https 为您的网络提供服务 用户在两周内的两天内访问了您的网站两次。 在 Google 的官方文档中阅读更多相关信息。 您可以使用特殊参数将 Google 登录按钮添加到您的页面,然后用户可以登录并指定直接从您的网站安装您的应用程序的设备。 这是我所知道的最“官方支持”的实现: https://developers.google.com/identity/sign-in/web/android-app-installs 来自链接: 通过将 Google 登录按钮添加到您的网站,您可以自动提示用户将您的 Android 应用程序通过无线方式下载到他们的 Android 设备上。要启用此功能,您必须为 Web 和 Android 客户端使用相同的 Google Developers Console 项目,并配置 Web 应用程序的登录按钮。 您的网络应用程序必须使用 Google 登录按钮来提示您的网站用户在首次登录时下载您的应用程序。通过将 apppackagename 参数添加到您的登录按钮即可启用此功能。 有两个可用的 API: 要检测应用程序是否已安装,请使用 getInstalledRelatedApps(仅适用于 Chrome 80+) 包含一般信息的文章:https://web.dev/get-installed-lated-apps/ 带有代码的文档和演示(网络+应用程序)https://www.chromestatus.com/feature/5695378309513216 显示提示安装您的应用程序 带有代码示例的文章:https://web.dev/customize-install/ 文档:https://developers.google.com/web/fundamentals/app-install-banners/native

回答 4 投票 0

Widget 未使用 AppWidgetManager 进行更新

我有一个可以通过按钮更新的小部件。单击该按钮时,所有字段中的值都会相应更新。这是onReceive方法代码: 覆盖 fun onReceive(context: Context, ...

回答 1 投票 0

我的小部件未使用 AppWidgetManager 更新,我该如何修复它?

我有一个可以通过按钮更新的小部件。单击该按钮时,所有字段中的值都会相应更新。这是onReceive方法代码: 覆盖 fun onReceive(context: Context, ...

回答 1 投票 0

如何实时更新glance小部件?

是否可以使用 Glance jetpack compose 实时更新 Widget 的数据?就像在数据库发生变化时更新数据一样。例如,当我使用 flow 时,flow 应该能够更新...

回答 1 投票 0

Glance App Widget 在 Android 8.0 上不会更新,而在 Android 12.0 上一切正常

我按照所有开发规则制作了一个GlanceAppWidget。 通过这个来自 android 的教程和这个来自 Google 主要开发人员的视频。 我制作了一个很酷的小部件,使用 MVVM 和现代

回答 0 投票 0

更改对话框在屏幕android

我在我的 Activity 中制作了一个简单的 AlertDialog: 查看 view = layoutInflater.inflate(R.layout.my_dialog, null); AlertDialog infoDialog = new AlertDialog.Builder(MyActivity.this) .设置...

回答 18 投票 0

将 PendingIntent 中的小部件的附加信息传递给 Activity

我找不到一种方法可以将附加功能从小部件正确传递到 Activity。 我不想在点击按钮时打开活动并传递一些额外信息。 意图 intent = new Intent(context, CreateOperationsActiv...

回答 2 投票 0

小部件配置屏幕。我想为我的应用程序创建一个小部件配置屏幕,如下图所示?

我想为我的应用程序创建一个小部件配置屏幕,如下图所示?请有人可以帮助我

回答 0 投票 0

如何在fillInIntent中设置数据

我的主屏幕小部件中有一个列表视图,我想在单击该项目时启动一个挂起的意图。我参考了这个并为每个列表项设置了一个 fillInIntent,然后设置了一个待处理的意图

回答 1 投票 0

在android中点击更新应用小部件

我正在开发 Android Widget,我的小部件如下图所示, [上一条] 活动名称 [下一条] prev,next 是小部件上的按钮。所以我想在单击 next 和 prev b 时更新事件名称...

回答 4 投票 0

Jetpack Compse Glance Widget API 33 在 API 30 作品上不可调整大小

我正在一目了然地创建应用程序小部件。在我的个人手机上,API 30 可调整大小适用于模拟器 API 33 或 32 可调整大小不起作用。 是模拟器的问题吗?但是 Google Chrome 小部件可调整大小的工作......

回答 1 投票 0

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