android - 工具栏中的进度条未在android中显示
问题描述
我有以下xml
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="@color/colorPrimary"
android:id="@+id/toolbar">
<ProgressBar
android:id="@+id/toolbarprogress"
android:layout_width="25dp"
android:shadowColor="@color/red"
android:rotation="@integer/google_play_services_version"
android:layout_height="25dp" />
</androidx.appcompat.widget.Toolbar>
在我的活动中,我有这两种方法
protected fun showProgress() {
toolbarprogress?.let {
it.visibility = View.VISIBLE
}
}
protected fun hideProgress() {
toolbarprogress?.let {
it.visibility = View.GONE
}
}
当我调用 showProgress 方法时它没有显示在我的工具栏中的问题,任何人都可以建议这里缺少什么吗?
解决方案
我使用了相同的代码,并且它与我的工作正常。setSupportActionBar(toolbar)
如果您的工具栏不可见,请确保使用。
推荐阅读
- java - Java StAX - 解析时出错 - 非法字符实体:扩展字符代码 0x19
- spring - 忽略zuul过滤器中的特定路径而不是一般路径
- apache-spark - 如何设置 HDFS 文件系统以使用 HDFS 运行 Spark 作业?
- xpath - 使用 xpath 获取特定节点位置
- css - 为什么` `标签设置为`display:block`有不规则的焦点轮廓形状?
- typescript - 如何调试从 create-react-app 创建的应用程序使用的本地打字稿模块
- gpflow - 我们如何在 GPflow 中为多输出 GP 的每个输出维度建模独立噪声?
- c# - 无法在应用启动时显示警报 Xamarin Forms
- ansible - 无法在 Ansible 中获得命令模块的完整输出
- android - 如何在 Kotlin 中仅显示 Cloud Firestore 集合中的 15 个随机项目?