简体   繁体   中英

Android Studio - ProgressBar will not render

I am attempting to use a progressbar within my layout. I do not understand why it will not render. It doesn't show in my preview and it also doesn't show when I run the app through my actual phone. Any ideas why this would happen?

Here is my layout XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:background="#283341"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_startup" tools:context=".StartupActivity">

    <ImageView
        android:id="@+id/startupImg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="50dp"
        android:layout_marginTop="150dp"
        android:layout_centerInParent="true"
        android:src="@drawable/q_orange" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:layout_marginBottom="30dp">

        <ProgressBar
            android:id="@+id/loadingSpinner"
            style="?android:attr/progressBarStyleSmall"
            android:layout_centerInParent="true"
            android:layout_width="33dp"
            android:layout_height="33dp"
            android:visibility="visible"
            android:indeterminate="true"
            />

        <TextView
            android:id="@+id/startupStatus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="Loading..."
            android:textColor="#ff8a07"
            android:textSize="25sp" />
    </LinearLayout>

</RelativeLayout>

在Android Studio中预览

Try this and let me know whether it works or not :

     <ProgressBar
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     style="@android:style/Widget.ProgressBar.Small"
     android:layout_marginRight="5dp" />

set for progressbar

android:layout_width="100dp"
android:layout_height="wrap_content"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM