【问题标题】:How do I remove the top and bottom spacing from the Material Horizontal Progress Bar?如何从材料水平进度条中删除顶部和底部间距?
【发布时间】:2016-05-13 17:15:22
【问题描述】:

我对 Holo 进度条做了同样的事情,方法是编辑可绘制的 png 以从文件外部删除填充,但是我找不到材质栏的可绘制 png。如果有人能指出我如何找到它,那就太好了!

我看到有人建议我简单地将 ProgressBar 设置为负上边距或下边距,但这并不是一个真正合适的解决方案,并且在不同手机之间并不一致。

我的 XML 当前如下所示:

<FrameLayout
    android:id="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="@dimen/header_height"
    android:background="@color/green">

    <ProgressBar
        android:id="@+id/ticket_state_progress_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:indeterminate="true"
        style="?android:attr/indeterminateProgressStyle"/>

</FrameLayout>

和风格:

<style name="linear_progress" parent="Widget.AppCompat.ProgressBar.Horizontal">
    <item name="android:indeterminateTint">@color/progress_bar_yellow</item>
    <item name="android:backgroundTint">@color/progress_bar_yellow_background</item>
</style>

目前,ProgressBar 出现在标题底部上方几个像素处,尽管该空间也被 ProgressBar 视图覆盖。我希望酒吧本身与标题的底部齐平。提前感谢您提供的任何帮助:)

【问题讨论】:

  • 你的布局中只有ProgressBar吗?尝试使用android:layout_height="match_parent" 而不是“wrap_content”
  • 不幸的是,框架布局要大得多,因为它代表一块颜色,底部有进度条。但是我可以尝试将 ProgressBar 放入具有指定高度的另一个视图中。我会试试看,然后回复你:)

标签: android progress-bar material-design


【解决方案1】:

添加负边距(android:layout_marginTopandroid:layout_marginBottom):

<ProgressBar
  android:id = "@+id/myProgressBar"
  style = "?android:attr/progressBarStyleHorizontal"
  android:layout_width = "match_parent"
  android:layout_height = "wrap_content"
  android:layout_marginTop="-6dp"
  android:layout_marginBottom="-6dp"/>

【讨论】:

    猜你喜欢
    • 2021-03-28
    • 2020-12-05
    • 1970-01-01
    • 1970-01-01
    • 2011-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-01
    相关资源
    最近更新 更多