android之在工具栏中显示进度条
虾米哥
阅读:84
2024-12-31 21:38:35
评论:0
我想在 Activity 工具栏底部的更新过程中显示一个 ProgressBar。但是,我仍然没有找到合适的解决方案。我应该如何开始?
我已经尝试过使用 FrameLayout 或将 ProgressBar 放入工具栏中。不幸的是,它看起来从未与这些相似:
如何做这样的事情?我的 Intent 是当 ProgressBar 消失时布局不会改变。
请您参考如下方法:
在您的 xml 布局上尝试以下操作
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<!-- Here your ProgressBar -->
<ProgressBar
android:id="@+id/progress"
android:layout_marginTop="-7dp"
android:layout_marginBottom="-7dp"
android:indeterminate="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:fabSize="normal"
app:srcCompat="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
结果会是这样
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。