Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android进度条删除默认填充_Android_Progress Bar_Android View - Fatal编程技术网

Android进度条删除默认填充

Android进度条删除默认填充,android,progress-bar,android-view,Android,Progress Bar,Android View,我目前正在我的应用程序中使用progressbar,在顶部和底部有一个我想删除的填充。我甚至不确定它是否真的是填充物。。您可以在下图中看到,pb本身的上方和下方都有空白 我试着玩它,ofc在谷歌上搜索,我看到了很多定制绘图和类似的例子,是这样吗? 我想知道做这件事的最佳做法是什么。。有什么建议吗 我现在的代码(非常简单): 添加图像以显示pb上方和下方的空白: 这样您就可以使用 <ProgressBar android:id="@+id/pc_progressbar"

我目前正在我的应用程序中使用progressbar,在顶部和底部有一个我想删除的填充。我甚至不确定它是否真的是填充物。。您可以在下图中看到,pb本身的上方和下方都有空白

我试着玩它,ofc在谷歌上搜索,我看到了很多定制绘图和类似的例子,是这样吗? 我想知道做这件事的最佳做法是什么。。有什么建议吗

我现在的代码(非常简单):


添加图像以显示pb上方和下方的空白:

这样您就可以使用

<ProgressBar
    android:id="@+id/pc_progressbar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="@null"
    android:paddingTop="@null"
    android:progressTint="@color/azure"/>

您可以更改该值以适合您的布局

还是用这种风格

<style name="HorizontalProgressBarStyle" 
    parent="Widget.AppCompat.ProgressBar.Horizontal">
    <item name="android:background">@null</item>
    <item name="android:scaleY">@null</item>
    <item name="android:scaleX">@null</item>
    <item name="android:padding">@null</item>
</style>

@空的
@空的
@空的
@空的

希望这有助于将
进度条的高度设置为4dp。创建一个高度为4dp的
框架布局
,并将
进度条的
布局设置为
中心

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="4dp">

    <ProgressBar
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="4dp"
        android:layout_gravity="center"/>

</FrameLayout>


嘿,伙计,首先非常感谢你的帮助!我不确定这实际上是一个填充问题,但无论如何,你的解决方案不起作用。嗨,Sonn,谢谢你的帮助!将高度设置为4dp会删除设备上的空白,无需框架布局。。想知道这是否是最好的解决方案tho,它是否适用于所有大小的设备?这被认为是“最佳实践”吗?您好@JozeRi,您可以在这里选择最佳解决方案:dd的副本
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="4dp">

    <ProgressBar
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="4dp"
        android:layout_gravity="center"/>

</FrameLayout>