I'm moving my app's ActionBar to ActionBarSherlock and I'm trying to customize the background with a tiled background. I'm testing my code on 2 real devices, one running Android 2.1 and the other running Android 4.0.4.
The code below is working on the ICS device (the background does repeat) but not on the Eclair one (the background is stretched instead of repeating). I've also tested this on Android 2.3 emulator and the background does not repeat too. It seems the tileMode="repeat" is only working on ICS.
themes.xml:
<style name="Theme.Opheodrys.Base" parent="Theme.Sherlock.Light">
<item name="android:actionBarStyle">#style/Opheodrys.Widget.ActionBar</item>
<item name="actionBarStyle">#style/Opheodrys.Widget.ActionBar</item>
</style>
<style name="Opheodrys.Widget.ActionBar" parent="Widget.Sherlock.Light.ActionBar">
<item name="android:background">#drawable/ab_background_pattern</item>
<item name="background">#drawable/ab_background_pattern</item>
</style>
ab_background_pattern.xml:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/ab_background_tile"
android:tileMode="repeat"
tileMode="repeat" /> <!-- I've added this just in case, but it doesn't seem to be needed -->
This is Android bug #15340 and not an ActionBarSherlock bug.
You can fix this with something similar to:
BitmapDrawable bg = (BitmapDrawable)getResources().getDrawable(R.drawable.bg_striped);
bg.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
getSupportActionBar().setBackgroundDrawable(bg);
Related
We are trying to migrate (because of a crash, that seem related to this - Here's another question for my crash.
Our existing Splash-Screen which also serves as routing.
Previously we used a full screen vector as a theme of splash screen, after following the documentation -
https://developer.android.com/develop/ui/views/launch/splash-screen/migrate#prevent_the_custom_activity_from_displaying
and updated the theme like this -
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">#drawable/ic_launcher</item>
<item name="background">#drawable/background_splash</item>
<item name="postSplashScreenTheme">#style/AppTheme</item>
</style>
background_splash is the drawable image that we want to have in full screen there. Its not working?
Splash screen is looking distorted, the windowSplashScreenAnimatedIcon is cropped and put into a small circle in the center.
Anyone has idea how to achieve this correctly? Thank you for your time!
Is it possible to provide a full screen drawable to splash in accordance with the new splash API for android 12+ with backward compatibility?
Searched for a solution working with Android-12 as well as with older versions and didn't like to create multiple resolution images. Android-12 changed the behaviour of the splash screen (migration guide) but this resulted in a well sized icon either for Android-12 or for earlier versions, but not for both.
Finally I ended up with a trick, to add two splash screen xml files, one for version 12 and higher, the other for all other versions. Give the item (parent of the image) a size in dp, and the bitmap a gravity="fill". The size differs for both splash_screen xml, I don't know if there is an official solution to this problem.
resources/values/styles.xml
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#387aa8</item>
<item name="windowSplashScreenAnimatedIcon">#drawable/splash_screen</item>
<item name="postSplashScreenTheme">#style/MainTheme</item>
</style>
resources/drawable/splash_screen.xml
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="224dp" android:height="224dp" android:gravity="center">
<bitmap
android:src="#drawable/silent_notes_256"
android:gravity="fill"/>
</item>
</layer-list>
resources/drawable-v31/splash_screen.xml (Android-12 and higher)
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="128dp" android:height="128dp" android:gravity="center">
<bitmap
android:src="#drawable/silent_notes_256"
android:gravity="fill"/>
</item>
</layer-list>
While I did tests with different resolutions, I don't know whether this works for all screen size/resolution combinations.
I've followed Migrate your splash screen implementation, and it promises that After you migrate using the SplashScreen compat library, the system displays the same splash screen on all versions of Android.
I've created the new splash theme, but the issue is that, I don't have an option to put windowSplashScreenBrandingImage for style belowe values-v31, that is, for android lower than 12.
So the bottom bar that we have been using previously can'be shown as of now.
values-v31/style
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.App.SplashThemeNew" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#android:color/white</item>
<item name="windowSplashScreenAnimatedIcon">#drawable/splash_icon</item>
<item name="android:windowSplashScreenBrandingImage">
#drawable/background_splash_12_bottom_strp
</item>
<item name="postSplashScreenTheme">#style/AppTheme</item>
</style>
</resources>
style
<style name="Theme.App.SplashThemeNew" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#color/white</item>
<item name="windowSplashScreenAnimatedIcon">#drawable/splash_icon</item>
<item name="postSplashScreenTheme">#style/AppTheme</item>
</style>
While according to the Migration guide, it should be possible, Has anyone some ideas about this?
Thanks for your time and attention.
Unfortunately it is not possible to use the android:windowSplashScreenBrandingImage on api lower than 31. This issue has officially been reported as a feature request on the IssueTracker, but for now they say that it won't be implemented (Source). However, it is still assigned so it might get implemented in the future.
Besides that, the Android docs state that The design guidelines recommend against using a branding image.
That being said, I found an Medium article that might help you achieve what you are looking for.
I have a 3 devices, they run from android 10,11 and 12. But the device on android 12 seems to have an issue with windowBackground. I have used the windowBackground as a splashscreen/loadingscreen. This appears to work fine on android 10 and 11 but on android 12 it seems to pick a different image, which I think is my applogo image.
This is the splash_image
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/papaya_orange"/>
<item android:drawable="#drawable/logo_transparant_white_loading_screen"
android:width="250dp"
android:height="95dp"
android:gravity="center" />
</layer-list>
In my styles.xml I have made this:
<style name="LoadingScreen" parent="DarkMode">
<item name="android:windowBackground">#drawable/splash_image</item>
<item name="android:statusBarColor">#color/papaya_orange</item>
</style>
In the manifest I have set the theme to android:theme="#style/LoadingScreen" >
And in my mainactivity I already declared that It switches themes, so nothing wrong there.
So this should work fine, but for some odd reason it doesn't work on android 12 like how it works on 10 and 11. Any guesses on why this doesn't work?
The problem is Android 12 migrations for Splash Screen. Check migration official documentation.
I use Android project(old project) on Eclipse.
I install ADT from here:
https://dl-ssl.google.com/android/eclipse/
In my manifest.xml
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
snippet of xml layout:
<Spinner
android:id="#+id/currencySpinner"
style="#style/racommon_spinner_custom_style"
android:layout_width="0dip"
android:layout_height="40dip"
android:layout_weight="0.3"
android:prompt="#string/currency" />
here styles.xml
<style name="racommon_spinner_custom_style" parent="#android:style/Widget.Holo.Light.Spinner">
<item name="android:background">#drawable/racommon_spinner_custom_bg</item>
<item name="android:clickable">true</item>
</style>
Here drawable racommon_spinner_custom_bg:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="#drawable/spinner_selected_custom_border"/>
<item android:state_focused="true" android:state_pressed="true" android:drawable="#drawable/spinner_pressed_custom"/>
<item android:drawable="#drawable/spinner_default_custom" />
</selector>
here res\drawable-mdpi\spinner_pressed_custom.9.png
Here result on Android 4.3
and here result on Android 6.0+
Here when click on spinner:
As you can see the background of spinner is different than on Android 4.0. On android 4.0. is correct spinner's background. But in android 6.0+ not correct.
Here result nine-pathch generator
Why?
I think its a problem of dpi, so i would suggest you make 9 patch image according to dpi
go to Below Link
Click Here
and Drag your current 9 patch image here, it will generate the images according to dpi.
Since you aren't setting gradient background programmatically, the problem is just with the style used from deprecated theme: Widget.Holo.Light.Spinner.
Just replace it with up to date theme like Widget.AppCompat.Light.Spinner.
Also you can try just to update targetSdkVersion and use more recent SDK version if that's an option for you.
Some clarification:
the actual cause of the gradients to be broken on newer Android versions is the new requirement to specify values in dp, see Android Gradient on Lollipop not working. - API 21
I have an app that is using Viewpagerindicator. I am using the tabs portion of it. I use a black background and the default blue indicator color. I wanted to add an actionbar to my app so I started using Actionbarsherlock. In order to get my tabs to show an the action bar to show I created my own them which is called in my manifest file. The theme I created is this:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is our main ActionBarSherlock theme -->
<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
</style>
<style name="Theme.VPI" parent="Theme.Styled">
<item name="vpiTitlePageIndicatorStyle">#style/Widget.TitlePageIndicator</item>
<item name="vpiTabPageIndicatorStyle">#style/Widget.TabPageIndicator</item>
<item name="vpiTabTextStyle">#style/Widget.TabPageIndicator.Text</item>
</style>
</resources>
When I run the app, I get my blue indicator color but the background of the entire app is white.
Originally I was how this code inside:
<style name="Theme.VPI" parent="Theme.Styled">
<item name="vpiTabPageIndicatorStyle">#style/CustomTabPageIndicator</item>
</style>
That gave me red indicators with a white background. I know the custom tabs are red with a white background and that is why I changed it from CustomTabPageIndicator to Widget.TabPageIndicator. However, I am still getting an all white background.
I have tried to just make my layout have a black background inside of my pageviewer, however when I do that, my buttons become really dark and unreadable.
My main question is to find where I can change the color inside of the Viewpagerindicator theme.
Any suggestions would be much appreciated. Thank You.
Visit this example; Making ActionBarSherlock and ViewPagerIndicator play nice
Possible Bug in that example; Android - SupportMapFragment with GoogleMaps API 2.0 giving IllegalArgumentException
Good Luck..!!