【问题标题】:progressBarStyle not working on Android StudioprogressBarStyle 在 Android Studio 上不起作用
【发布时间】:2021-08-02 05:54:15
【问题描述】:

我在使用 Android Studio 时遇到问题。

任务:app:processDebugResources 失败 AGPBI: {"kind":"error","text":"Android 资源链接失败","sources":[{"file":"/Users/luisabsg/.gradle/caches/transforms-2/files-2.1 /270e51d2bcfda0833b0b336f50197a8a/jetified-folioreader-0.5.4/res/layout/progress_dialog.xml","position":{"startLine":16}}],"original":"ERROR:/Users/luisabsg/.gradle/caches /transforms-2/files-2.1/270e51d2bcfda0833b0b336f50197a8a/jetified-folioreader-0.5.4/res/layout/progress_dialog.xml:17: AAPT: 错误: 资源 android:attr/android:progressBarStyle 未找到。\n ","tool ":"AAPT"}

任务“:app:processDebugResources”执行失败。

执行 com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction 失败 Android资源链接失败 错误:/Users/luisabsg/.gradle/caches/transforms-2/files-2.1/270e51d2bcfda0833b0b336f50197a8a/jetified-folioreader-0.5.4/res/layout/progress_dialog.xml:17:AAPT:错误:资源android:attr/android :progressBarStyle 未找到。

  • 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。

【问题讨论】:

    标签: android progress-bar


    【解决方案1】:
    AAPT: error: resource android:attr/android:progressBarStyle not found.
    

    您将进度条的样式设置为 R.style.Widget_ProgressBar_Horizontal 。终于

    style="@android:style/Widget.ProgressBar.Horizontal"
    

     style="?android:attr/progressBarStyleHorizontal"
    

    仅供参考

    Android 资源链接失败 错误:/Users/luisabsg/.gradle/caches/transforms-2/files-2.1/270e51d2bcfda0833b0b336f50197a8a/jetified-folioreader-0.5.4/res/layout/progress_dialog.xml:17

    在您的项目应用模块中 转到:- Your-Project-Location -> /app/src/main/res/layout/ 并创建文件 progress_dialog.xml 并设置以下代码:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:id="@+id/layout_loading"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:gravity="center">
            <ProgressBar
                android:id="@+id/loading"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                style="?android:attr/progressBarStyle" />
            <TextView
                android:id="@+id/label_loading"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="4dp"
                android:textSize="18sp"
                android:textColor="@android:color/white"
                android:text="@string/loading" />
        </LinearLayout>
    </RelativeLayout>
    

    【讨论】:

    • 问题是当我更改然后编译时,它会恢复到以前的状态......好像它没有保存,即使我同步了
    • @areatech 这怎么可能。 Clean-Rebuilds-Restart
    • youtu.be/qSgpi09MriU我做了一个短视频演示
    • @areatech 此 XML 在您自己的 xml 或任何库 xml 中?
    • 我在我的项目中找不到这个progress_dialog.xml文件,只是在我电脑上的一个文件夹中
    【解决方案2】:

    你使用了错误的样式属性,你应该在你的进度样式中使用style="?android:attr/progressBarStyle"

     <ProgressBar
        android:id="@+id/loading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="?android:attr/progressBarStyle"/>
    

    【讨论】:

    • 我改变了它,但每次我编译它,它都会回到 android:progressBarStyle
    • 清理项目并重建它。
    • 使缓存失效并从文件菜单选项重新启动
    • 在将样式从style="?android:attr/android:progressBarStyle" 更改为style="?android:attr/progressBarStyle" 后,您的错误是改变了还是还是一样?
    • 它保持不变。我更改并同步项目,它一直在变化。当我编译时,它会返回到之前编写的内容。如果你愿意,我可以让我的项目可用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-05
    • 2013-05-13
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 2018-06-18
    • 2014-03-16
    相关资源
    最近更新 更多