2016-12-14 79 views
2

我有一個應用程序,我在幾個地方使用ProgressBar。ProgressBar不顯示

<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,但它不起作用。

下面是我的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,但它不是出現在所有。 過帳樣品視圖:

<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中,我也沒有重寫清單中的活動主題。它是應用程序級別的默認主題。 即使我創建一個只有進度條的新活動,它也不會出現。 在所有活動設計預覽中都很奇怪,進度條顯示正常,但運行應用程序時卻沒有。 如果需要其他信息,請讓我知道。

+0

你正在使用進度條的帖子佈局 –

+0

也許在上面有另一個'View'?完整的佈局會有所幫助。 – Sunshinator

+0

已添加。我在應用程序的幾個地方使用它。我已經發布了一個這樣的實例 – proy31

回答

0

我當時也面臨同樣的問題,可能它的存在,但由於其他意見隱藏。我做了什麼你的情況將在XML輕微更改文件

<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"/> 

究竟只是進度條上的其他高層,這個工作對我來說,我不知道爲什麼。