6

私は次のレイアウトを持っています:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.pontai"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <com.markupartist.android.widget.ActionBar
        android:id="@+id/actionbar"
        style="@style/ActionBar"
        android:layout_marginBottom="3dip"
        app:textStyleActionBar="@style/TextViewStyleHeader"
        app:title="@string/app_name" />

    <com.fb.design.SegmentedButton
        android:id="@+id/main_action_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:btnText1="@string/sb_friends"
        app:btnText2="@string/sb_search"
        app:btnText3="@string/sb_summary"
        app:gradientColorOffEnd="@color/segmented_button_off_end"
        app:gradientColorOffStart="@color/segmented_button_off_start"
        app:gradientColorOnEnd="@color/segmented_button_on_end"
        app:gradientColorOnStart="@color/segmented_button_on_start"
        app:gradientColorSelectedEnd="@color/segmented_button_selected_end"
        app:gradientColorSelectedStart="@color/segmented_button_selected_start"
        app:whichButtonIsSelected="0" />

    <View
        android:layout_width="wrap_content"
        android:layout_height="2dp"
        android:layout_marginBottom="3dip"
        android:background="@drawable/gradient_line" >
    </View>

    <LinearLayout
        android:id="@+id/linearLayout7"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/linearLayout4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/buttonAddFriends"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_input_add"
                android:clickable="true"
                android:height="40dp"
                android:width="40dp" />

            <EditText
                android:id="@+id/search_box"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:hint="@string/type_here_to_filter"
                android:inputType="text"
                android:maxLines="1"
                android:padding="10dp" >
            </EditText>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/loadingPanel"
            style="@style/GenericProgressBackground"
            android:layout_height="match_parent" >

            <ProgressBar style="@style/GenericProgressIndicator" />
        </LinearLayout>

        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1" />

        <TextView
            android:id="@id/android:empty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingLeft="5dp"
            android:text="@string/empty_results" />
    </LinearLayout>
</LinearLayout>

私のアクティビティには、完了時に次のことを行う AsyncTask があります。

((LinearLayout)findViewById(R.id.loadingPanel)).setVisibility(View.GONE);

したがって、基本的には、ProgressBar を保持する LinearLayout があり、必要なデータがある場合は、この linearlayout の可視性を GONE に設定します。

これは私のGalaxy Nexusでは機能していますが、カスタムROMを使用して、API 8エミュレーターやGalaxy S2でも機能していません。

誰もこれを見たことがありますか?

私の最悪のシナリオは、プログレス バーを含むこの linearlayout を XML から削除し、コードに ProgressDialog を追加することです。

よろしく、フェリペ

アップデート

これは私がstyles.xmlを定義した方法です

 <style name="GenericProgressBackground" parent="android:Theme">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:background">#77ffffff</item>
        <item name="android:gravity">center</item>
    </style>

    <style name="GenericProgressIndicator" parent="@android:style/Widget.ProgressBar.Large">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:indeterminate">true</item>
    </style>

UPDATE2 問題を修正しました

 <ProgressBar
                android:id="@+id/progressBar1"
                style="?android:attr/progressBarStyleLarge"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

私はアンドロイド属性から来るスタイルを追加しましたが、それだけでうまくいきました...私が作成したスタイルでなぜそれがうまくいかなかったのかわかりません...それは奇妙です.

助けてくれてありがとう!:)

4

6 に答える 6

4

使った結果は

<ProgressBar
        style="@android:style/Widget.DeviceDefault.ProgressBar.Large"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />
于 2012-04-27T14:24:37.673 に答える
2

これは、アニメーションがオフになっている一部のデバイスで発生する可能性があります。アニメーションを再びオンにすると、問題ないはずです。

于 2017-03-30T13:34:19.437 に答える
1

私も同じ問題を抱えていました。xml レイアウト ファイルのスプラッシュ画面にプログレス バーを追加したかったのですが、画面の Eclipse プレビューにプログレス バーが表示されているのを確認できましたが、コードを実行すると、それが見えず、数回夢中になりました。時間。最後に、FrameLayout にプログレス バーを追加し、FrameLayout の下位層の子である別の RelativeLayout にスプラッシュ バックグラウンド イメージを描画して、問題を解決しました。私の背景画像は 9patch 画像だったので、実行時にプログレスバーを上書きしていたのかもしれません。しかし、ここに私の解決策があります:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/splash" />

    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|center_horizontal"
        android:layout_marginTop="150dp"
        android:visibility="visible" />

</FrameLayout>

それが役に立てば幸い!

于 2013-10-26T19:18:56.210 に答える
0

HTC U11 でバッテリー セーバーが自動的にオンになるという奇妙な問題が発生しました。オフにしたのに、スピナーが表示されませんでした。

次に、開発者設定を完全にオフにし、アプリを再起動すると、スピナーが表示され始めました。

于 2020-06-22T20:25:51.613 に答える