progressBarStyle 不适用于 Android Studio

progressBarStyle not working on Android Studio

我对 Android Studio 有疑问。

Task :app:processDebugResources FAILED AGPBI: {"kind":"error","text":"Android resource linking failed","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: error: resource android:attr/android:progressBarStyle not found.\n ","tool":"AAPT"}

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

A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction Android resource linking failed ERROR:/Users/luisabsg/.gradle/caches/transforms-2/files-2.1/270e51d2bcfda0833b0b336f50197a8a/jetified-folioreader-0.5.4/res/layout/progress_dialog.xml:17: AAPT: error: resource android:attr/android:progressBarStyle not found.

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

 <ProgressBar
    android:id="@+id/loading"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="?android:attr/progressBarStyle"/>
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 resource linking failed ERROR:/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>