在 xml 布局中,当我单击进度条时,我确实看到它位于我希望的位置,但在实时时,我看不到它,感觉它隐藏在按钮下方。
我试过了:
- 更改 View 的定位(进度条上方/下方的按钮)
- 不确定
- 玩转 ProgressBar 的风格
似乎没有任何效果。
这是我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<Button
android:id="@+id/button_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:elevation="1dp"
android:text="test button" />
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button_id"
android:layout_alignTop="@+id/button_id"
android:layout_centerHorizontal="true"
android:indeterminate="true"
android:indeterminateTint="@android:color/holo_blue_dark"
android:visibility="visible" />
</RelativeLayout>
最佳答案
问题与海拔
有关。将 elevation
添加到 ProgressBar
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<Button
android:id="@+id/button_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:elevation="1dp"
android:text="test button" />
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button_id"
android:layout_alignTop="@+id/button_id"
android:layout_centerHorizontal="true"
android:indeterminate="true"
android:elevation="2dp"
android:indeterminateTint="@android:color/holo_blue_dark"
android:visibility="visible" />
</RelativeLayout>
关于android - 按钮中间的进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38745098/