进度条不显示 [英] ProgressBar not displaying

查看:109
本文介绍了进度条不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用,我在几个地方使用了 ProgressBar.

I have an app where I have used ProgressBar in several places.

<ProgressBar
    android:id="@+id/pb_loading_indicator"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:indeterminate="true"
    android:visibility="visible"/>

所有进度条都没有出现在任何活动中.我已经通过以编程方式更改进度条的颜色并添加 xml drawable 来尝试所有解决方案,但它不起作用.

All the progressbars are not appearing in any activity. I have tried all solutions by changing the color of the progressbar programmatically and by adding an xml drawable, but its not working.

下面是我的styles.xml

Below is my styles.xml

<style name="MyAppCompatTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:colorPrimary">#FFFFFF</item>
    <item name="android:colorPrimaryDark">#F1F1F1</item>
    <item name="android:colorAccent">#EF5350</item>
</style>

从技术上讲,进度条应该采用 colorAccent,但它根本没有出现.发布示例视图:

Technically the progressbar should take the colorAccent, but its not appearing at all. Posting a sample view:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/logo"
    android:src="@drawable/app_icon"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="120dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_below="@+id/logo"
    android:textSize="18sp"
    android:id="@+id/subtitle"
    android:textColor="@color/secondary_text"
    android:layout_marginTop="30dp"
    android:text="QUICK BROWN FOX"/>

<ProgressBar
android:id="@+id/pb_loading_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="visible"/>

进度条不会与应用程序的任何活动中的任何视图重叠.我的styles.xml 中没有任何其他主题,我也没有覆盖清单中的活动主题.它是一个应用程序级别的默认主题.即使我创建一个只有进度条的新活动,它也不会出现.这很奇怪,因为在所有活动设计预览中,进度条正确显示,但在运行应用程序时却没有.如果需要其他信息,请告诉我.

The progressbar is not overlapped by any view in any activity of the app. I dont have any other theme in my styles.xml and I am not overriding the activity theme in the manifest also. Its an application level default theme. Even if i create a new activity with only a progressbar, it doesnt appear. It is weird as in all the activity design previews, the progress bar appears properly but on running the app it doesnt. Please let me know if some other info is required.

推荐答案

我也面临同样的问题,可能它在那里但因为其他视图而隐藏了.我在你的情况下所做的会在 xml 文件中略有变化

I was too facing same problem, may its there but hiding because of other views. what i did in your case would minor change in xml file

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ProgressBar
android:id="@+id/pb_loading_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="visible"/>


<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/logo"
    android:src="@drawable/app_icon"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="120dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_below="@+id/logo"
    android:textSize="18sp"
    android:id="@+id/subtitle"
    android:textColor="@color/secondary_text"
    android:layout_marginTop="30dp"
    android:text="QUICK BROWN FOX"/>

除了其他顶部的进度条之外什么都没有,这对我有用,我不知道为什么.

exactly nothing but progress bar on top of other, this work for me i don't know why.

这篇关于进度条不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆