i'm using the sherlock actionbar library in order to support many devices . i have a viewPager which has 3 fragments :
one with a listView , each item has a textView and an imageView
the second has a gridView , each item has a textView and an imageView
the third just has a textView for now.
as i've heard in google IO videos (and since Lint tells me) , it's recommended to have the next style being used for all of the activities:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="android:windowBackground">#null</item>
</style>
</resources>
this has worked for me on many devices .
however , on the emulator , using version 2.3.3 , and on galaxy nexus , when i scroll (either the viewPager or any of the adapterViews) , everything just smears , so i get a lot of white pixels as if nothing was refreshed.
i've even tried to set android:cacheColorHint="#00000000" for all of my adapterViews , but it still occurs.
what is going on? how can i fix this thing ? i like adding the above since it removes the ugly gradient background of galaxy S3 that appears for every app.
You should only set the background to nul if you cover it with something else. Either:
- Set the background to null in the theme and add a new background in your layout
or
- Set the background in your theme to the color/image you want.
Related
I have an android application which is running on production for several years. Lately, I have discovered a problem with a ListView in the app, that gets blurry while scrolling. The problem only occurs under Android Marshmallow.
Here is a screenshot of the ListView while scrolling
Any help would be much appreciated.
Thanks!
Preface: I posted a separate answer prior to this one, but that solution only worked on my MotoX. I later discovered it did not work for my Galaxy Tab A. The answer here seems to be more universal:
I was able to fix my scrolling blur by defining a separate ListView style for my application and specifying a different list divider. So, for my application theme I set this:
<item name="android:listViewStyle">#style/ListViewStyleNoBlur</item>
Where ListViewStyleNoBlur is defined as:
<style name="ListViewStyleNoBlur" parent="#android:style/Widget.ListView.White">
<item name="android:divider">#android:drawable/divider_horizontal_bright</item>
</style>
I specified these in a values-v23 resources folder so the change doesn't affect pre-Marshmallow devices.
My application theme is based off of android:style/Theme.Light, which is why my list view style's parent is android:style/Widget.ListView.White. My app min SDK is 8, which is why I'm using such an "old" theme. I also noticed that if I use a "newer" theme, such as Holo, the blur does not exist.
I also had this problem and, through trial-and-error, finally found a solution. Hopefully it will also work for you. This appears to be a bug in Marshmallow related to the scroll bar in list views. I had the following property set in my application theme, and removing this property fixed the blurry scrolling:
<item name="android:fadeScrollbars">false</item>
Using true instead of false also works, but is unnecessary since it is the default. I also discovered (through trail-and-error) that using android:fastScrollEnabled="true" causes the same blurring, but based on your scrollbar style, you do not appear to be using it.
In summary, don't use android:fadeScrollbars. If that doesn't fix your issue, try playing around with any other scrollbar-related styles you may be using on your ListView, bearing in mind these styles may be part of the view directly, or part of an activity or application theme.
I have this design to achieve:
but the result I got is this:
As you can see I am asked to create the submit button much larger that it actually is, I've tried setting it as an image with no luck, also I've tried entering it as normal text and manipulate the theme but that didn't work either, I'm using the latest and greatest API 21 .. Lollipop.
here's the code to the item in my menu:
<item
android1:title="submit"
android1:id="#+id/userLoginSubmitActionBar"
app:showAsAction="always|withText"/>
Have you tried using android:actionLayout attribute of the <item> tag? It will let you set a custom layout to be displayed. You could use a TextView and set the text size appropriately :)
As for the arrows, if I am not wrong, < means up navigation while <- means presence of a navigation drawer, right?
This is really a hack I suppose but what the hell, here's my solution to my own contribution,
I've set
<item name="android:actionMenuTextAppearance">
to my own custom theme parenting from
<style name="myStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
and the damn thing worked like magic ! haha... thank u guys, really, no need for the drum rolls in the background :D
i'm using the sherlock actionbar library in order to support many devices . i have a viewPager which has 3 fragments :
one with a listView , each item has a textView and an imageView
the second has a gridView , each item has a textView and an imageView
the third just has a textView for now.
as i've heard in google IO videos (and since Lint tells me) , it's recommended to have the next style being used for all of the activities:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="android:windowBackground">#null</item>
</style>
</resources>
this has worked for me on many devices .
however , on the emulator , using version 2.3.3 , and on galaxy nexus , when i scroll (either the viewPager or any of the adapterViews) , everything just smears , so i get a lot of white pixels as if nothing was refreshed.
i've even tried to set android:cacheColorHint="#00000000" for all of my adapterViews , but it still occurs.
what is going on? how can i fix this thing ? i like adding the above since it removes the ugly gradient background of galaxy S3 that appears for every app.
You should only set the background to nul if you cover it with something else. Either:
- Set the background to null in the theme and add a new background in your layout
or
- Set the background in your theme to the color/image you want.
I have an activity which shows a full screen videoView (yet maintain the aspect ratio). It worked perfectly on Android 2.3.7, but i'm having some weird problems on Android 4 (and probably 3, i didn't check yet):
For some reason, if I set the theme to be full screen, without the titlebar (or action bar), i get a blue-ish (or white-ish?) gradient below the videoView, as shown here:
The relevant layout is here:
edit: on android 3 , it doesn't occur.
When I change the orientation from portrait to landscape, it re-loads the whole video from the beginning. On Android 2.3.7, it continued without any delay, as if nothing has changed.
The relevant manifest part is here:
<activity android:name=".activities.player_activity.PlayerActivity" android:configChanges="keyboardHidden|orientation"
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" android:screenOrientation="sensor"/>
Note that on Android 3, rotating the tablet doesn't do anything, so there is no orientation change.
How should I handle those problems ? The API demos don't seem to be updated to handle those cases.
My project was tested on: nexus one (android 2.3.7) , xoom (android 3) , galaxy S3 (android 4).
In order to fix number 1, I've simply changed the theme that doesn't have any background. Odd that it's this way on the device. Wonder if it's like this on other Android 4 devices. In order to create the theme, I've created a file "theme.xml" in the "res/values/" folder, and wrote there:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.FullScreenNobarsNoBackground" parent="#android:style/Theme.Holo.NoActionBar.Fullscreen">
<item name="android:windowBackground">#null</item>
</style>
</resources>
Of course I've also updated the manifest to use the new theme.
When you change the device orientation, the Dalvik kills the activity and create another, and garbage collector clean all the old stuff.
I suggest to you forces the application stay in horizontal mode, you can do that change the follow attribute in activity:
<activity android:screenOrientation="landscape" />
If you wanna the activy change the orientation, you must handler the change. You can read this documentation how to handling runtime changes.
I'm afraid I can't see the gradient you're talking about on that image. But if it is on the whole screen, then this is probably the standard background for Holo themes and you can just remove it using a custom theme.
As for the restarting on rotation, you could save the current time in onConfigurationChanged(..) and then use VideoView.seekTo(..) to then get it back to the correct time in an appropriate part of your code. However, I don't know why this should happen in ICS because you're not destroying the Activity.
In the new official Twitter app, the scrollbars in all the ListViews the app uses are hidden unless the user is scrolling through the list.
When you start scrolling, the scrollbars appear. When you stop, they fade out with an animation until they are gone completely.
I can't seem to find anything in the documentation that indicates this as being a standard feature.
Is this something included in the API? If not, anyone know how this might be done?
Confirmed : either use android:fadeScrollbars ( if you're API level 5 )
or try to use setOnScrollListener to check scroll status and hide/show the bars . Some code examples are in this thread:
how to detect Android ListView Scrolling stopped?
You can enable scroll bar fading for your entire app on API level 5 and newer via a custom theme and the fadeScrollbars style attribute by adding this to styles.xml:
<style name="Theme.App" parent="android:Theme.Light">
<item name="android:fadeScrollbars">true</item>
</style>
Then set the new theme for your application in AndroidManifest.xml:
<application android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:description="#string/description"
android:theme="#style/Theme.App">
Just be sure you're not overriding this global theme on individual activities. Earlier Android versions will safely ignore this unknown XML attribute and not fade the scrollbars.
I haven't used them yet, but you might play around with android:scrollbarDefaultDelayBeforeFade and android:scrollbarFadeDuration, available on all widgets (i.e., subclasses of View).
I followed Alex's answer and it worked using both the theme settings and through code.
GridView gridview = (GridView) findViewById(R.id.mygridView);
gridview.setScrollbarFadingEnabled(false);
I did encounter a problem however with the Gallery Component. Whilst the following will compile fine, it will throw a NullPointerException. I assume this is to do with a Gallery not having scrollbars to show/hide.
Gallery gallery = (Gallery) findViewById(R.id.myGallery);
gallery.setScrollbarFadingEnabled(false); // <-- this will throw an exception
Android 2.2