I have the following layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="#android:style/Widget.Material.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
I have a Nexus 5 running Android 5.0.1 that doesn't display the ProgressBar, obviously because of the style. When I set the style for example to
style="#android:style/Widget.ProgressBar.Large"
or
style="#android:style/Widget.Holo.ProgressBar.Large"
it is shown. I have an identical Nexus 5 also running Android 5.0.1 which displays all the ProgressBars fine.
Enabling the 'draw layout borders' option in the developers options, it shows that the ProgressBar is included in the layout, it is simply not shown.
This seems very strange, any idea on what could be going on here?
I was having the same issue but was because the developer phone have animations scales to 0 (all 3).
Enable all the animations on the device and maybe you will be able to see the progress bar, so for normal people that will have animations enabled the progress bar will appear fine.
In my case, it looks as if the issue is with build LRX22G:
Nexus 7 using Build LRX22G (android-5.0.2_r1) - progress bar not shown
Nexus 5 using Build LRX22C (android-5.0.1_r1) - progress bar shown
See https://source.android.com/source/build-numbers.html
It's probably also related with https://code.google.com/p/android/issues/detail?id=77865
Not being able to wait for a fix, what I've decided to do is to force the Holo progress bar to be used in my Material theme. This is how it was achieved - it may be of some use to you in the meantime:
<style name="AppBaseTheme" parent="#android:style/Theme.Material.Light.DarkActionBar">
<!-- Build LRX22G (5.0.2 Nexus 7) fails to display progress bar so we'll use Holo instead of Material -->
<!-- http://stackoverflow.com/questions/27567235/certain-progressbar-styles-not-shown-on-nexus-5-android-5-0-1 -->
<item name="android:progressBarStyleSmall">#style/MaterialProgressBarFix.Small</item>
<item name="android:progressBarStyle">#style/MaterialProgressBarFix</item>
<item name="android:progressBarStyleLarge">#style/MaterialProgressBarFix.Large</item>
</style>
<style name="MaterialProgressBarFix.Small" parent="#android:style/Widget.Holo.ProgressBar.Small" />
<style name="MaterialProgressBarFix" parent="#android:style/Widget.Holo.ProgressBar" />
<style name="MaterialProgressBarFix.Large" parent="#android:style/Widget.Holo.ProgressBar.Large" />
By setting the style to the following instead you should be able to debug this issue
style="?android:attr/progressBarStyleLarge"
Related
Created own color in color.xml <color name="colorProgressBar">#006600</color>
In styles.xml
<style name="ProgressBarde">
<item name="colorAccent">#color/colorProgressBar</item>
</style>
and added this to the main .xml activity
<ProgressBar
android:id="#+id/progressBar3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true"
android:theme="#style/ProgressBarde" />
As you can the I choosed green color for my progress bar. It's even changed to my android studio editor. But when run it on my real android device by usb It's not changing. Where is my mistake?
Are you running your app on a pre-Lollipop device? On these devices the Material-themed progress bars are not available. instead, they are replaced with the default Holo progress bar. You can try using a third-party library for this.
(This should have been a comment, but my reputation is too low.)
I have the following layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="#android:style/Widget.Material.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
I have a Nexus 5 running Android 5.0.1 that doesn't display the ProgressBar, obviously because of the style. When I set the style for example to
style="#android:style/Widget.ProgressBar.Large"
or
style="#android:style/Widget.Holo.ProgressBar.Large"
it is shown. I have an identical Nexus 5 also running Android 5.0.1 which displays all the ProgressBars fine.
Enabling the 'draw layout borders' option in the developers options, it shows that the ProgressBar is included in the layout, it is simply not shown.
This seems very strange, any idea on what could be going on here?
I was having the same issue but was because the developer phone have animations scales to 0 (all 3).
Enable all the animations on the device and maybe you will be able to see the progress bar, so for normal people that will have animations enabled the progress bar will appear fine.
In my case, it looks as if the issue is with build LRX22G:
Nexus 7 using Build LRX22G (android-5.0.2_r1) - progress bar not shown
Nexus 5 using Build LRX22C (android-5.0.1_r1) - progress bar shown
See https://source.android.com/source/build-numbers.html
It's probably also related with https://code.google.com/p/android/issues/detail?id=77865
Not being able to wait for a fix, what I've decided to do is to force the Holo progress bar to be used in my Material theme. This is how it was achieved - it may be of some use to you in the meantime:
<style name="AppBaseTheme" parent="#android:style/Theme.Material.Light.DarkActionBar">
<!-- Build LRX22G (5.0.2 Nexus 7) fails to display progress bar so we'll use Holo instead of Material -->
<!-- http://stackoverflow.com/questions/27567235/certain-progressbar-styles-not-shown-on-nexus-5-android-5-0-1 -->
<item name="android:progressBarStyleSmall">#style/MaterialProgressBarFix.Small</item>
<item name="android:progressBarStyle">#style/MaterialProgressBarFix</item>
<item name="android:progressBarStyleLarge">#style/MaterialProgressBarFix.Large</item>
</style>
<style name="MaterialProgressBarFix.Small" parent="#android:style/Widget.Holo.ProgressBar.Small" />
<style name="MaterialProgressBarFix" parent="#android:style/Widget.Holo.ProgressBar" />
<style name="MaterialProgressBarFix.Large" parent="#android:style/Widget.Holo.ProgressBar.Large" />
By setting the style to the following instead you should be able to debug this issue
style="?android:attr/progressBarStyleLarge"
Samsung devices with Android 5.0 ignore my color for the progressbar (set in styles.xml). The default blue color of samsung is used instead.
<style name="Progress">
<item name="colorControlActivated">#000000</item>
</style>
The progressbar is in a toolbar:
<android.support.v7.widget.Toolbar
...
>
<ProgressBar
android:id="#+id/progress_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:theme="#style/Progress"/>
</android.support.v7.widget.Toolbar>
Any ideas?
As far as I remember, this topic will help: https://medium.com/the-wtf-files/the-misterious-case-of-the-skewed-progressbar-75da47ddd767.
You should add an attribute: android:indeterminateDrawable="#drawable/progressbar" to a ProgressBar and also add a drawable. It is useful for infinite ProgressBar. If it's determinate, I will research a problem and report here. Also see: How to change color in circular progress bar?.
For those who don't see a ProgressBar at all, see https://github.com/DreaminginCodeZH/MaterialProgressBar/issues/1. Maybe an "Animation scale" in Developer Options of your device is turned off.
See also: https://github.com/DreaminginCodeZH/MaterialProgressBar.
I am developing a simple app in Android Studio, and I am testing it on a real device (Asus zenfone 5 & Android 4.4.2). In the main activity I have applied this layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="madapps.mysecondapp.MainActivity"
android:id="#+id/activity_main" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?android:attr/actionBarSize"
android:orientation="horizontal"
android:background="#drawable/background_deathstar">
<EditText
android:id="#+id/edit_message"
android:text="#string/message" android:layout_weight="1"
android:layout_width="0dp" android:layout_height="wrap_content"
android:hint="#string/edit_message" android:textColor="#FFF" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
with this style.xml applied to the activity
<resources>
<style name="AppTheme" parent="android:Theme.Holo">
<item name="android:windowActionBarOverlay">true</item>
</style>
</resources>
What I want to do is testing a background image on different screen sizes and densities (dpi).
Now, the problem is that while in my physical device the property
android:windowActionBarOverlay
is applied properly, laying out my action bar on top of my background image, this is not working equally within Android Studio's layout editor, meaning that my image begins at the end of the action bar.
ps. I have also noticed that apart from ignoring the windowActionBarOverlay property, my action bar fails to load my custom action buttons. I think these two problems are somewhat related.
Any suggestions?
Thank you very much
Apparently I should have not expected Android Studio's layout editor to reflect what I'm seeing on devices, because it's only using a subset of the real Android layout system.
Actually my action bar is hidden and shown programmatically, and the layout editor is only supposed to serve as a way to drag-and-drop widgets and preview a layout while editing the XML.
I have a problem where the spinner I use display correctly in the emulator but incorrectly on the phone.
This can best be illustrated with this screen shot taken from the phone (notice the light grey background behind the words 'App Priorities 1'):
What it's supposed to look like is like this (taken from the emulator). Here is the text is white and the background black as it should be.
I'm not sure what all the relevant parts of the code is, but I have a folder called values-v14 that contains a single file called styles.xml. The file's contents is:
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
</resources>
This is the spinner XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="fill_horizontal"
android:orientation="vertical" >
<TextView
android:id="#android:id/text1"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</RelativeLayout>
I'm not sure if the manifest is relevant, but I have this in there:
android:minSdkVersion="15"
android:targetSdkVersion="15"
I tried setting the version to 14 but that didn't make any difference.
UPDATE: After adding android:theme="#style/AppTheme" to the Manifest both the emulator and the phone has consistent behavior. The action bar is now dark as it should be. But all the lists have a white background!
Change your AppTheme to Theme.Holo instead of Theme.Holo.Light.DarkActionBar and you'll get your dark background back.
Theme.Holo.Light.DarkActionBar is the same as Theme.Holo.Light (light colored everything) just with, you guessed it, a darker ActionBar.
I am guessing that the phone has the Android 2.x version of Android whereas the emulator is using Android 3+. This means that the emulator has the Holo theme while the phone does not. You have to either create your own theme that copies the Holo theme or live with the fact that it's going to look different on different versions of Android. It's definitely more work to make sure that it still looks good across all versions but it also leads to a more seamless experience.