【问题标题】:ProgressBar gap进度条间隙
【发布时间】:2016-03-09 04:21:16
【问题描述】:

Check this image for the progressbar

知道如何消除进度条下的那个小间隙吗? 我怎样才能做到没有差距?它应该是通过 MainActivity 中的 java 代码还是...? 这是我的布局 xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<android.support.v7.widget.Toolbar
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<ProgressBar
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="wrap_content"
    android:layout_height="2.9dp"
    android:id="@+id/progressBar"
    android:background="@android:color/transparent"
    android:layout_alignParentStart="true"
    android:layout_alignParentEnd="true"
    android:layout_alignBottom="@id/my_toolbar"/>

<WebView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/webView"
    android:layout_alignParentEnd="true"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/my_toolbar"
    android:layout_alignParentBottom="true" />

</RelativeLayout>

【问题讨论】:

  • 为 ProgressBar 提供负填充
  • 你的意思是有点余量先生?
  • 是的 marginBottom = -10dp 明智的
  • 因为它已经是 android:layout_alignBottom="@id/my_toolbar" 我给了它一个 -2dip 并且它工作了谢谢你先生的帮助,一切顺利! :)
  • 该空间看起来不像来自ProgressBar。它可能在 WebView 内 - 在这里查看如何删除 (stackoverflow.com/questions/8694184/…)

标签: android xml


【解决方案1】:

只给Progressbar添加负边距

更新代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<android.support.v7.widget.Toolbar
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<ProgressBar
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="wrap_content"
    android:layout_height="2.9dp"
    android:id="@+id/progressBar"
    android:background="@android:color/transparent"
    android:layout_alignParentStart="true"
    android:layout_alignParentEnd="true"
    android:layout_alignBottom="@id/my_toolbar"
    android:layout_marginBottom="-2dip"
/>

<WebView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/webView"
    android:layout_alignParentEnd="true"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/my_toolbar"
    android:layout_alignParentBottom="true" />

</RelativeLayout>

【讨论】: