如何将 ProgressBar 的样式更改为小?

发布于 2024-09-14 07:37:53 字数 75 浏览 20 评论 0原文

我很难找到正确的方法来指定进度条应该具有小的不定样式。

如果有人能为我和其他人提供一个快速搜索此信息的示例,我会很高兴。

I have some difficulties finding the correct way to specify that a progress bar should have the small indefinite style.

I would be glad if somebody could provide an example for me and others that do a quick search for this information.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

一指流沙 2024-09-21 07:37:53

解决方案是将样式更改为

<ProgressBar
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   style="?android:attr/progressBarStyleSmall" />

The solution is to change the style to

<ProgressBar
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   style="?android:attr/progressBarStyleSmall" />
相思碎 2024-09-21 07:37:53

另一种方法是

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

Ex_

<ProgressBar
 android:id="@+id/progress_bar"
 style="@android:style/Widget.ProgressBar.Small"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:padding="7dip"
 arandroid:visibility="visible" />

One more way to do it is

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

Ex_

<ProgressBar
 android:id="@+id/progress_bar"
 style="@android:style/Widget.ProgressBar.Small"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:padding="7dip"
 arandroid:visibility="visible" />
清风挽心 2024-09-21 07:37:53

以下是如何以编程方式执行此操作:

ProgressBar progress = new ProgressBar(ctx, null, android.R.attr.progressBarStyleSmall);

Here is how to do it programmatically:

ProgressBar progress = new ProgressBar(ctx, null, android.R.attr.progressBarStyleSmall);
玩套路吗 2024-09-21 07:37:53

这可能有用:

style="?android:attr/android:progressBarStyleSmall"

This may be of use:

style="?android:attr/android:progressBarStyleSmall"
孤芳又自赏 2024-09-21 07:37:53

您可以通过scaleX和scaleY属性轻松更改进度条的大小,如下所示:

<ProgressBar
        android:id="@+id/progressBar"
        android:scaleX="0.5"
        android:scaleY="0.5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

这里,

scaleX:更改宽度,因此0.5会将宽度减少到实际宽度的一半

scaleY:改变高度,因此0.5会将高度减少到实际高度的一半

You can change the size of progress bar easily by scaleX and scaleY property, like this:

<ProgressBar
        android:id="@+id/progressBar"
        android:scaleX="0.5"
        android:scaleY="0.5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

Here,

scaleX: To change the width, so 0.5 will reduce the width to the half of the actual width

scaleY: To change the height, so 0.5 will reduce the height to the half of actual height

墨洒年华 2024-09-21 07:37:53
 <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content
        style="?android:attr/progressBarStyleSmallTitle"
        android:layout_height="wrap_content" />
 <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content
        style="?android:attr/progressBarStyleSmallTitle"
        android:layout_height="wrap_content" />
美人迟暮 2024-09-21 07:37:53
<!--changing of color,small size spinner-->
    <style name="progressColor" parent="@android:style/Widget.ProgressBar.Small">
        <item name="colorControlActivated">@color/colorPrimary</item>
    </style>

您可以通过在微调器中使用上述样式来实现彩色和小尺寸微调器

<ProgressBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/progressColor"
            android:layout_gravity="center" />
<!--changing of color,small size spinner-->
    <style name="progressColor" parent="@android:style/Widget.ProgressBar.Small">
        <item name="colorControlActivated">@color/colorPrimary</item>
    </style>

you can achieve color and small size spinner by using above style in spinner

<ProgressBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/progressColor"
            android:layout_gravity="center" />
掩耳倾听 2024-09-21 07:37:53

根据@Rupesh Yadav的回答,您可以看到样式@android:style/Widget.ProgressBar.Small的结构:

<style name="Widget.ProgressBar.Small">
    <item name="indeterminateDrawable">@drawable/progress_small_white</item>
    <item name="minWidth">16dip</item>
    <item name="maxWidth">16dip</item>
    <item name="minHeight">16dip</item>
    <item name="maxHeight">16dip</item>
</style>

我可以确认设置最小和最大尺寸可以解决问题。显式设置宽度和高度不会更改 ProgressBar 的大小。所以你可以打造自己的风格。

According to the answer of @Rupesh Yadav, you can see a structure of the style @android:style/Widget.ProgressBar.Small:

<style name="Widget.ProgressBar.Small">
    <item name="indeterminateDrawable">@drawable/progress_small_white</item>
    <item name="minWidth">16dip</item>
    <item name="maxWidth">16dip</item>
    <item name="minHeight">16dip</item>
    <item name="maxHeight">16dip</item>
</style>

I can confirm that setting min and max sizes solves the problem. Setting width and height explicitly doesn't change the size of the ProgressBar. So you can make your own style.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文