Android ProgressBar在某些设备中不显示
我的布局如下:Android ProgressBar在某些设备中不显示,android,android-layout,progress-bar,Android,Android Layout,Progress Bar,我的布局如下: <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="fi
<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>
因此,基本上,我有一个保存着ProgressBar的LinearLayout,当我有了所需的数据时,我将这个LinearLayout的可见性设置为Goe
这在我的Galaxy Nexus上运行,但在我的API 8仿真器和Galaxy S2上使用自定义ROM时不起作用
有人见过这个吗
我最糟糕的情况是从XML中删除这个带有进度条的线性布局,并在代码中添加一个进度对话框
问候,,
菲利佩
更新
这就是我如何定义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>
填补家长的空缺
填补家长的空缺
#77ffffff
居中
包装内容
包装内容
真的
更新2
我解决了这个问题
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
我添加了来自android属性的样式,这一点本身就很有效。。。我不知道为什么它不符合我创造的风格。。。真奇怪
谢谢你的帮助!:) 使用的结果是什么
<ProgressBar
style="@android:style/Widget.DeviceDefault.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
我也有同样的问题。我想在xml布局文件的初始屏幕上添加一个进度条,我可以在Eclipse屏幕预览中看到进度条,但是当我运行代码时,它是不可见的,这让我疯狂了好几个小时。最后,我通过在FrameLayout中添加进度条解决了这个问题,将飞溅背景图像绘制在不同的RelativeLayout中,后者是FrameLayout的较低层子级。我的背景图像是一个9patch图像,所以它可能在运行时覆盖了我的progressbar。但我的解决方案是:
<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>
希望有帮助 关闭动画时,某些设备上可能会发生这种情况。再次打开动画,您应该会没事。在某些设备上,进度条无法显示,因为在“设置”->“开发人员选项”->“过渡动画比例”中处于关闭状态 将此设置切换到ON(通常为x 1)将使进度条再次显示
我想有一个正确的解释,但我没有完整的答案为什么关闭动画会使进度条不工作。我的解决方案是从相对布局切换到线性布局。工作相当顺利。下面的代码希望对您有所帮助 activity_main.xml:
<LinearLayout
android:id="@+id/leniar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="@color/colorPrimary"
android:baselineAligned="false"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="3">
<ProgressBar
android:id="@+id/progressBarlite"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:theme="@style/ProgressBarlit" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:layout_marginBottom="-1dp"
android:background="@color/colorPrimaryDark"
android:visibility="visible">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true">
</WebView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
为了让这项功能发挥作用,您必须将重力作为进度条和包含进度条的线性布局的“中心”,这一点非常重要
<LinearLayout
android:gravity="center"/>
<ProgressBar
android:gravity="center"/>
</LinearLayout>
以下是my styles.xml:
<resources>
<style name="ProgressBarlit" parent="Theme.AppCompat">
<item name="colorAccent">@color/progressback</item>
<item name="android:minWidth">32dp</item>
<item name="android:maxWidth">50dp</item>
</style>
<style name="ProgressBardrk" parent="Theme.AppCompat">
<item name="colorAccent">@color/colorAccentDarkprgress</item>
<item name="android:minWidth">32dp</item>
<item name="android:maxWidth">50dp</item>
<item name="android:minHeight">32dp</item>
<item name="android:maxHeight">100dp</item>
</style>
</resources>
@颜色/进度返回
32dp
50dp
@颜色/颜色重音深绿色
32dp
50dp
32dp
100dp
希望它能有所帮助,我知道它回答的不仅仅是这个问题,但你会在这里找到你的答案我在HTC U11上遇到了一个奇怪的问题,我们的电池节电器自动打开,我关闭了它,但旋转器仍然没有出现
然后我完全关闭了开发人员设置,重新启动了应用程序,然后微调器开始显示,希望它能帮助别人。这应该在线性布局中吗?如果没有,如何隐藏进度条?是的,您可以将其放入线性布局
,但不要忘记在线性布局上添加android:layout\u width=“match\u parent”是的,不幸的是,这不起作用。实际上,您的建议已经在my styles.xml中定义。当然,请在UPDATE2部分找到它,Alexandre,它已经起作用了。我在上面发布了解决方案。谢谢:)很高兴听到你找到了一个解决方案,你可以投票支持我来感谢我;-)我找到了更好的解决办法。如果未在9patch上标记“填充区域”,则无法添加任何内容,或者添加的内容将不可见。要解决此问题,请明智地标记9patch图像的“填充区域”,并将FrameLayout的背景设置为此9patch图像。然后可以在标记的区域中看到FrameLayout的子级。有关9patch图像的更多信息,请查看它工作不正常,请告诉我其他一些提示@SniperHey@ManikandanK您有什么问题?progressbar是否在某些设备上工作,但在其他设备上不工作?你的progressbar(在每台设备上)难道一点都不工作吗?你能看到屏幕上的进度条吗?如果你看到progressbar做的是旋转?对我来说,它是我设置为关闭的动画持续时间比例。禁用这些设置可以加快应用程序之间的转换,让手机看起来运行得更快,这是很流行的做法。对我来说,这也是动画师的持续时间尺度。打开它(到1x)后,我可以再次看到progressbar
<LinearLayout
android:gravity="center"/>
<ProgressBar
android:gravity="center"/>
</LinearLayout>
<resources>
<style name="ProgressBarlit" parent="Theme.AppCompat">
<item name="colorAccent">@color/progressback</item>
<item name="android:minWidth">32dp</item>
<item name="android:maxWidth">50dp</item>
</style>
<style name="ProgressBardrk" parent="Theme.AppCompat">
<item name="colorAccent">@color/colorAccentDarkprgress</item>
<item name="android:minWidth">32dp</item>
<item name="android:maxWidth">50dp</item>
<item name="android:minHeight">32dp</item>
<item name="android:maxHeight">100dp</item>
</style>
</resources>