ProgressBar在某些设备中未显示 [英] ProgressBar not showing in some devices

查看:52
本文介绍了ProgressBar在某些设备中未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的布局如下:

<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,完成后会执行以下操作:

My Activity has a AsyncTask that upon completion does the following:

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

因此,基本上,我有一个LinearLayout持有我的ProgressBar,并且当我有需要的数据时,我将此线性布局的可见性设置为GONE.

So, basically I have a LinearLayout holding my ProgressBar and, when I have the data I need, I set the visibility to GONE for this linearlayout.

这在我的Galaxy Nexus上可以找到,但是在我的API 8仿真器上以及在使用自定义ROM的Galaxy S2上都无法使用.

This is working find on my Galaxy Nexus, but it's not working on my API 8 Emulator and also in the Galaxy S2, using a custom ROM.

有人见过吗?

最糟糕的情况是从XML中删除带有进度条的线性布局,并在代码中添加一个ProgressDialog.

My worst case scenario will be removing this linearlayout with a progress bar from the XML and add a ProgressDialog in the code.

关于, 费利佩

更新

这就是我定义styles.xml的方式

This is how I defined the 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" />

我添加了来自android属性的样式,仅此一种就起作用了……我不知道为什么它不能与我创建的样式一起起作用……这很奇怪.

I added the style coming from the android attributes and that alone worked... I have no idea why it didnt work with the style I created... it's weird.

感谢您的帮助! :)

推荐答案

在某些设备上,进度栏无法显示,因为在设置"->开发人员选项"->过渡动画比例"中为关闭".

On some devices the progress bar could not appear because in Settings -> Developer Options -> Transition Animation Scale is OFF.

将此设置切换为ON(通常为1)将使进度条再次出现.

Switching this setting to ON (usually x 1) will make the progress bar to appear again.

我想对此有一个正确的解释,但是我没有完整的答案,为什么关闭动画会使进度条不起作用.

I guess there is a proper explanation about that, but I do not have complete answer why animations off make the progress bar to not work.

这篇关于ProgressBar在某些设备中未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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