Включая круговой индикатор выполнения в виджете приложения для Android - PullRequest
0 голосов
/ 03 октября 2018

Я пытаюсь создать виджет для своего приложения.В виджете есть круговой индикатор выполнения.Индикатор поддержки компонента виджета, поэтому из учебника я нашел здесь .Я создал круговой индикатор выполнения и смог просмотреть его в виджете.Но индикатор выполнения имеет много отступов или полей со всех сторон, которые я пытался удалить, но потерпел неудачу.Из-за этого дополнительного пространства я не могу выровнять другое содержимое в виджете.Кто-нибудь может мне помочь с этим?Заранее спасибо ..

ОБНОВЛЕНИЕ

Добавление кодов макета

Макет виджета

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:CircleProgressView="http://schemas.android.com/apk/res-auto"
android:background="@drawable/widget_baground"
android:paddingBottom="@dimen/widget_margin"
android:paddingTop="@dimen/widget_margin"
android:paddingRight="@dimen/widget_margin"
android:paddingLeft="@dimen/widget_margin_left"
android:orientation="horizontal">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/widget_p_u"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/widget_margin_top"
        android:paddingRight="15dp"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/widget_p_c_ll">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/widget_p_u"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="UVW"
                    android:layout_centerInParent="true"
                    android:textColor="@android:color/black"/>
            </RelativeLayout>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Xyz"
                android:layout_gravity="center_horizontal"
                android:textColor="@android:color/black"/>

        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/widget_p_d_ll"
            android:layout_alignLeft="@+id/widget_p_c_ll">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
                <ProgressBar
                    android:layout_width="150dp"
                    android:layout_height="150dp"
                    android:id="@+id/widget_p_u_progress_d"
                    android:indeterminate="false"
                    android:max="100"
                    style="?android:attr/progressBarStyleHorizontal"
                    android:progress="50"
                    android:progressDrawable="@drawable/widget_progress"
                    android:layout_marginBottom="-45dp"
                    android:layout_marginTop="-43dp"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:orientation="vertical">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="770.83"
                        android:textSize="12dp"
                        android:textColor="@android:color/black"
                        android:textStyle="bold"
                        android:id="@+id/widget_p_d_tv1"
                        android:textAlignment="center"
                        android:layout_gravity="center"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/widget_p_d_tv2"
                        android:text="of 800 left"
                        android:textSize="6dp"
                        android:layout_gravity="center"/>
                </LinearLayout>
            </RelativeLayout>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Efg"
                android:textColor="@android:color/black"
                android:layout_gravity="center_horizontal"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/widget_p_s_ll"
            android:layout_alignLeft="@+id/widget_p_d_ll">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
                <ProgressBar
                    android:layout_width="150dp"
                    android:layout_height="150dp"
                    android:id="@+id/widget_p_u_progress_s"
                    android:indeterminate="false"
                    android:max="100"
                    style="?android:attr/progressBarStyleHorizontal"
                    android:progress="40"
                    android:progressDrawable="@drawable/widget_progress"
                    android:layout_marginBottom="-45dp"
                    android:layout_marginTop="-43dp"/>
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:orientation="vertical">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="23"
                        android:textSize="18dp"
                        android:textColor="@android:color/black"
                        android:textStyle="bold"
                        android:id="@+id/widget_p_s_tv1"
                        android:textAlignment="center"
                        android:layout_gravity="center"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/widget_p_s_tv2"
                        android:text="of 100 left"
                        android:textSize="8dp"
                        android:layout_gravity="center"/>
                </LinearLayout>
            </RelativeLayout>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Abc"
                android:textColor="@android:color/black"
                android:layout_gravity="center_horizontal"/>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/widget_p_days_rem"
            android:text="20"
            android:textStyle="bold"
            android:textColor="@android:color/black"
            android:textSize="24dp"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="days remaining "
            android:textSize="20dp"
            android:textColor="@android:color/black"/>
    </LinearLayout>
</LinearLayout>

<!--Refresh button -->
<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/widget_margin_top"
    android:src="@drawable/refresh"
    android:layout_gravity="right"/>

Drawable для индикатора выполнения: - widget_progress

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/secondaryProgress">
    <shape
        android:innerRadius="20dp"
        android:shape="ring"
        android:thicknessRatio="20.0"
        android:useLevel="false">

        <gradient
            android:centerColor="#999999"
            android:endColor="#999999"
            android:startColor="#999999"
            android:type="sweep"/>
    </shape>
</item>

<item android:id="@+id/progress">
    <rotate
        android:fromDegrees="270"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="270">

        <shape
            android:innerRadius="20dp"
            android:shape="ring"
            android:thicknessRatio="20.0"
            android:useLevel="true">

            <rotate
                android:fromDegrees="0"
                android:pivotX="50%"
                android:pivotY="50%"
                android:toDegrees="360" />

            <gradient
                android:centerColor="#E60100"
                android:endColor="#E60100"
                android:startColor="#E60100"
                android:type="sweep"/>
        </shape>
    </rotate>
</item>

- это файлы макетов, которые я создал.Я попытался установить индикатор выполнения, добавив размер к этому элементу, индикатор выполнения сокращается, чтобы соответствовать этому размеру.Отрицательное заполнение также не работает для меня.

...