我在 Java 中创建了一个模拟时钟小部件,出于某种原因,我一直收到“问题加载小部件”,当我尝试放置小部件时,我从 logcat 中获得的唯一信息是:
2020-11-18 19:19:13.162 9482-9482/? E/Zygote: isWhitelistProcess - Process is Whitelisted
2020-11-18 19:19:13.162 9482-9482/? E/Zygote: accessInfo : 1
2020-11-18 19:19:13.166 9482-9482/? I/ckcustomizatio: Late-enabling -Xcheck:jni
2020-11-18 19:19:13.182 9482-9482/? E/ckcustomizatio: Unknown bits set in runtime_flags: 0x8000
2020-11-18 19:19:13.196 9482-9482/com.l_es.analogclockcustomization D/ActivityThread: setConscryptValidator
2020-11-18 19:19:13.196 9482-9482/com.l_es.analogclockcustomization D/ActivityThread: setConscryptValidator - put
Run Code Online (Sandbox Code Playgroud)
并且小部件只是一个带有“问题加载小部件”的黑色方块。
这是小部件类:
public class MainWidget extends AppWidgetProvider {
static RemoteViews views;
//preferences
private static SharedPreferences custClockPrefs;
//number of possible designs
private static int numClocks;
//IDs of Analog Clock elements
static int[] …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 android MotionLayout,但它找不到合适的类并且无法工作。
我尝试实现以下依赖项:
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha4'
Run Code Online (Sandbox Code Playgroud)
但它们似乎都不起作用......
这是我的 XML 文件:
<android.support.constraint.motion.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
footstools="http://schemas.android.com/tools"
android:id="@+id/motionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:showPaths="true"
tools:context=".PlayGameActivity">
<View
android:id="@+id/button"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@color/colorAccent"
android:text="Button" />
</android.support.constraint.motion.MotionLayout >'
Run Code Online (Sandbox Code Playgroud)
但它总是给我这个错误按摩:
Missing classes
The following classes could not be found:
- android.support.constraint.motion.MotionLayout (Fix Build Path, Edit XML, Create Class)
Tip: Try to build the project.
Tip: Try to refresh the layout.
Run Code Online (Sandbox Code Playgroud)
在项目的预览窗口中,它以灰色填充整个布局并在中心写入:
android...MotionLayout
Run Code Online (Sandbox Code Playgroud)