I created a notification with music player controls (shown below, Android 2.3.3) for my Android application. However, I'm facing an issue. In order to ensure standard behavior across all supported platforms (Android 2.2 - 4.2+) I set the notification background as black. I also couldn't use:
style="#android:style/TextAppearance.StatusBar.EventContent.Title"
style="#android:style/TextAppearance.StatusBar.EventContent"
for text styles since they aren't available in Android 2.2. Is this an appropriate design approach or is there a better alternative?
Related
Android added a way to deal with devices that have a notch/cutout at the top of the screen. (See Android and Xamarin.Android.) But as far as I can tell, Android automatically takes care of lowering the views so that they aren't obscured by the notch, so why do we need this new addition?
I tested my Android app on the emulator of a device with a notch and the app automatically goes below the notch without the need to specify layoutInDisplayCutoutMode as LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER.
So my question is, when would I need to use LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER?
In Xamarin that would be:
Window.Attributes.LayoutInDisplayCutoutMode = Android.Views.LayoutInDisplayCutoutMode.Never;
I'm running this on the Android Emulator through Visual Studio on a Windows computer. The emulator is emulating a Pixel 3 XL with Android Pie 9.0 (API 28). The app is an Android app created with Xamarin.Forms.
When you are creating a view, which uses full screen for showing content at that time notch display sometime hide/cut your top content.
To prevent this android provides support for this above android pie.
Refer to this document.
https://source.android.com/devices/tech/display/display-cutouts
I wanna create theme for both Android 5.0 and less android 5.0 application.
In first case for example I have Switch that if I don't set any background it appearance will change on Android 5.0 to like a slide button as you know,
but in less android 5.0 it show as on/off button.
when I put
android:thumb="#drawable/switch_selector"
to change thumb image and color it's fine on android 4.4 but my Switch show nothing on Android 5.0. my question is how to create a selector or theme for Switch that can show on all devices?
UPDATED
in simple way, we hava many drawable folders for each screen dpi's. I wanna know if I can set drawable for each Api's as like as for each dpi's ?!
after my hard times with Android notifications, where I need to do one method for android devices with Android 5.x and higher and another method for pre-Lollipop devices, I would advice you to search for additional libraries like this
SwitchButton
This project provides you a convenient way to use and customise a SwitchButton widget in Android. With just resources changed and attrs set, you can create a lifelike SwitchButton of Android 5.0+, iOS, MIUI, or Flyme and so on.
Now we get the biggest movement since SwitchButton published. v1.3.0 comes with totally reconsitution and more convenient API. A wholly new demo can give you a tour in it.
Github page: https://github.com/kyleduo/SwitchButton
More like this you would find here: http://android-arsenal.com/
Additional libraries may help you to avoid problems with backward compatibilities of Android components.
Like you said, you add this line of code:
android:thumb="#drawable/switch_selector"
and it works on Kitkat, but not on Lollipop.
I've found already that on Lollipop you may have much more to work.
Just take a look here: How to have a Lollipop switch button
So try to find your desired additional library like this above and let me know how it works ;-)
EDIT: To get API version use this:
Build.VERSION.RELEASE;
That will give you the actual numbers of your version; aka 2.3.3 or
2.2. The problem with using Build.VERSION.SDK_INT is if you have a rooted phone or custom rom, you could have a none standard OS (aka my
android is running 2.3.5) and that will return a null when using
Build.VERSION.SDK_INT so Build.VERSION.RELEASE will work no matter
what!
To use it, you could just do this;
String androidOS = Build.VERSION.RELEASE;
From: Retrieving Android API version programmatically
I'm writing an android app that has video content and references videos on YouTube. I implemented code in the Android 2.3 SDK and it properly runs. However, my phone updated to Android 4.0 and now the activity force closes. The activity simply uses image and text views to link, not a video view. What is the proper way to implement this activity in 4.0 that is backwards compatible with 2.3?
I am new in android development. And I have confusion about android layout compatibility.
I am creating one app in android 4.0.3 but it's UI look like android 2.2 related UI.
I used all default controls in app but it not look like 4.0.3 related UI.
So any one can help me in below problems.
If I am creating app in android 4.0.3 then how it's look in android 2.2 and vice versa?
How can I create app which is run in all android version with standard UI?
Please help me.
Thanks in advance.
Your app will use the system theme that you specify, or the custom styles that you specify. If you do not create custom themes or styles your app will use the default styles on each platform. So on 4.0.3 it will use the ICS theme, and on 2.2 it will use the older theme.
To create an app that will run on all versions, you should probably set your target API to 1.5, but there are few devices with 1.5 left, so you'll probably set your API target to 2.2, and this will make your application run on all the devices with Android 2.2+.
I'm working a personal project that's going to include a home-screen widget updated with information from a service - I'm developing using a Android 3.1 tablet (physical) as well as an Android 2.3 emulated phone.
For the Honeycomb version, I'd like to use the StackView, building up 3-4 pages which the user can swipe through, whereas this isn't supported on pre-Honeycomb devices, so is there an easy way to
have Honeycomb devices use a StackView but have Gingerbread/earlier use a TextView (I think this can be done by using res/layouts-v1{1,2,3,4}
Have the RemoteView detect which it is and clear/create the StackView items or set the text on the TextView
You can indicate different layout for pre and post Honeycomb by using the v11 qualifier in your layout names. You can also use the Build class to detect what Build version you're running on and then load the appropriate layout.