Закругленный прогресс в округленном индикаторе прогресса

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

17
задан TheIcemanCometh 20 June 2016 в 17:51
поделиться

3 ответа

Вы можете использовать эту библиотеку для индикатора выполнения закругленных углов

<com.akexorcist.roundcornerprogressbar.RoundCornerProgressBar
        android:layout_width="dimension"
        android:layout_height="dimension"
        app:rcProgress="float"
        app:rcSecondaryProgress="float"
        app:rcMax="float"
        app:rcRadius="dimension"
        app:rcBackgroundPadding="dimension"
        app:rcReverse="boolean"
        app:rcProgressColor="color"
        app:rcSecondaryProgressColor="color"
        app:rcBackgroundColor="color" />

Gradle

compile 'com.akexorcist:RoundCornerProgressBar:2.0.3'

https://github.com/akexorcist/Android-RoundCornerProgressBar

0
ответ дан Aditya Vyas-Lakhan 20 June 2016 в 17:51
поделиться

Вариант, который, возможно, немного более практичен, - реализация пользовательского представления Progress Bar.

public class CustomProgressBar extends View
{
    // % value of the progressbar.
    int progressBarValue = 0;

    public CustomProgressBar(Context context)
    {
        super(context);
    }

    public CustomProgressBar(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        progressBarValue = attrs.getAttributeIntValue(null, "progressBarValue", 0);
    }

    public void setValue(int value)
    {
        progressBarValue = value;
        invalidate();
    }

    protected void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);

        float cornerRadius = 30.0f;

        // Draw the background of the bar.
        Paint backgroundPaint = new Paint();
        backgroundPaint.setColor(Color.LTGRAY);
        backgroundPaint.setStyle(Paint.Style.FILL);
        backgroundPaint.setAntiAlias(true);

        RectF backgroundRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
        canvas.drawRoundRect(backgroundRect, cornerRadius, cornerRadius, backgroundPaint);

        // Draw the progress bar.
        Paint barPaint = new Paint();
        barPaint.setColor(Color.GREEN);
        barPaint.setStyle(Paint.Style.FILL);
        barPaint.setAntiAlias(true);

        float progress = (backgroundRect.width() / 100) * progressBarValue;
        RectF barRect = new RectF(0, 0, progress, canvas.getClipBounds().bottom);

        canvas.drawRoundRect(barRect, cornerRadius, cornerRadius, barPaint);

        // Draw progress text in the middle.
        Paint textPaint = new Paint();
        textPaint.setColor(Color.WHITE);
        textPaint.setTextSize(34);

        String text = progressBarValue + "%";
        Rect textBounds = new Rect();

        textPaint.getTextBounds(text, 0, text.length(), textBounds);

        canvas.drawText(text,
                backgroundRect.centerX() - (textBounds.width() / 2),
                backgroundRect.centerY() + (textBounds.height() / 2),
                textPaint);

    }
}

Тогда в вашем макете:

<view.CustomProgressBar
    android:layout_height="30dp"
    android:layout_width="match_parent"
    progressBarValue="66"/>

, что дает результат:

Custom progress bar result

4
ответ дан jverrijt 20 June 2016 в 17:51
поделиться

Вы также можете использовать панель поиска для этого

, проверьте мой пост здесь: https://stackoverflow.com/a/41206481/6033946

Попробуйте это, вы может быть в состоянии сделать то, что вы хотите, изменив цвет, ширину и высоту большого пальца и панель поиска в XML.

0
ответ дан Community 20 June 2016 в 17:51
поделиться
Другие вопросы по тегам:

Похожие вопросы: