Is it possible to get an uncropped splash screen in Android 12? - android-12

On Android versions older than Android 12 I am easily able to construct a splash screen with an image which is not cropped. For example like this on Android 11:
However, Android 12 introduced a new Splash Screen API and I can't figure out how to reproduce the splash screen above in Android 12. It seems that it is always cropped and turns out like this on Android 12:
This is my android/src/main/res/values/styles.xml for older Android versions (e.g. Android 11):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="#android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">#drawable/launch_background</item>
<item name="android:windowFullscreen">false</item>
</style>
<style name="NormalTheme" parent="#android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
This is my android/src/main/res/values-v31/styles.xml for Android 12:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="#android:style/Theme.Light.NoTitleBar">
<item name="android:windowSplashScreenAnimatedIcon">#drawable/launch_background</item>
<item name="android:windowFullscreen">false</item>
</style>
<style name="NormalTheme" parent="#android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
The only difference between the two styles.xml is that I use android:windowSplashScreenAnimatedIcon for Android 12 and android:windowBackground for older Android versions as stated in the documentation for the new splash screen API (https://developer.android.com/guide/topics/ui/splash-screen).
Both styles.xml use #drawable/launch_background which is defined in android/src/main/res/drawable/launch_background.xml as follows:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap android:gravity="fill" android:src="#drawable/background"/>
</item>
<item>
<bitmap android:gravity="center" android:src="#drawable/splash"/>
</item>
</layer-list>
#drawable/background is just a .png with a single white pixel (1x1) and splash.png (1280x721) is the actual image I want to show in the splash screen which should not be cropped. I uploaded both files here: https://imgur.com/a/IzyYAwP
With the new Android 12 Splash Screen API, is it even possible to get a splash screen which is identical to the result I got with Android 11 (no cropping of the background image)? If yes, how is that possible?

No, it's not possible. The goal of the new splash screen is to unify the Splash Screen UX and the cropping is part of the design.

Related

Can't determine type for tag in navigation menu

I upgraded my android studio to 4.0.1 and gradle to 6.6. I am getting this error
Can't determine type for tag '<item android:title="Menu">
<menu>
<item android:icon="#drawable/dashboard" android:id="#+id/dashoard" android:title="Dashboard"/>
<item android:icon="#drawable/hire" android:id="#+id/hire_mechanic_id" android:title="Hire a Mechanic"/>
</menu>
</item>'
Maybe you are missing a namespace in the menu element.
See sample.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/action_favorite"
android:icon="#drawable/ic_favorite_black_48dp"
android:title="#string/action_favorite"
app:showAsAction="ifRoom"/>
</menu>

android menu icon do not display

i am using appcompat for my actionbar for 2.3。
i want collapseActionView when i click the options but not display at first。
![enter image description here][1]
As the img shows ,the menus do not show icons.
Could somebody help me .tks very much.
here are my codes.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" >
<item
android:id="#+id/zhuangtai"
android:icon="#drawable/fa"
android:showAsAction="collapseActionView"
android:title="发状态"
app:showAsAction="collapseActionView"/>
<item
android:id="#+id/er"
android:icon="#drawable/sao"
android:showAsAction="collapseActionView|withText"
android:title="扫一扫"
app:showAsAction="collapseActionView|withText"/>
<item
android:id="#+id/sui"
android:icon="#drawable/sui"
android:showAsAction="collapseActionView|withText"
android:title="随份子"
app:showAsAction="collapseActionView|withText"/>
<item
android:id="#+id/haoyou"
android:icon="#drawable/haoyou"
android:showAsAction="collapseActionView|withText"
android:title="好友列表"
app:showAsAction="collapseActionView|withText"/>
</menu>
sorry for my english.
The android:showAsAction introduced in API Level 11. In this case you are using Api level 9. Read this tutorial. Its helps you.
collapseActionView The action view associated with this action item (as declared by android:actionLayout or android:actionViewClass) is collapsible.
Introduced in API Level 14.
So, one simple way is to remove collapseActionView

Android Dialog Divider Color

I'm trying to make the dialog divider color lime.
My theme is already defined in android manifest and all. I defined the color lime in color.xml as well.
However, the divider is still not changing color from the default blue of the holo light theme.
Here is my themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyCustomTheme" parent="android:Theme.Holo.Light.NoActionBar">
<item name="android:textColor">#3DE400</item>
<item name="android:divider">#color/lime</item>
</style>
</resources>
Here is my color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="lime">#3DE400</color>
</resources>
Please Help Me..
This is a style, so it should be in your styles.xml, not themes.xml. Also, make sure it's linked to somewhere in there so the app knows to use it. Otherwise you're just defining the style, but it's not being used. An option is instead of defining your own style, simply customize the existing one. E.g.:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.Holo.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#3DE400</item>
<item name="android:divider">#color/lime</item>
</style>

Layout like Cards in android

I want to make an android layout like Google Cards,i know there is an Open Source Libraries, however i want only the Layout and the gray hex background style. I could not find information about this, how i can make this possible? im Attaching new Google maps v7 Layout so you can get the idea.
bg_card.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#CCC" />
</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#FFF" />
</shape>
</item>
</layer-list>
Or just set the background of the card to #FFF and add at the bottom:
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#CCC" />
NOTE:
For everyone who doesn't care about using a library, you should use
a CardView from the Android support library.
Sample code.
<item name="android:windowBackground">#ffe3e3e3</item>
In your style.xml should make you happy ;-)
And for the layout, copying the card background should be enough isn't it?
We can use the LayerList as above to achieve this (OR) by using the nine patch image get same effect, we need not create nine patch image separately for this puprpose android drawable have one.
if you are using eclipse: android:background="#drawable/abc_menu_dropdown_panel_holo_light"
copy paste the above line as your View backround.
or if you are using android studio copy paste the following line:
android:background="#android:drawable/dialog_holo_light_frame"

Android Border Less Button Pressed State Background Color

How can we change the background colour of a Border less button when the button is pressed.
I used this:
android:background="?android:attr/selectableItemBackground"
android:text="#string/btn_skip"
Where my button Displays a label "SKIP" as defined in my "strings.xml".
Now When I test this it is Good Except It shows default "Blue" Colour when in Pressed State.
I want it to match it with other elements of my My UI theme that are "Orange" "#FF8800"
Any Ideas?
Thankx in advance...!
instead of using ?android:attr/selectableItemBackground you can create a xml in drawable in folder with following content.
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true">
<item
android:state_pressed="true"
android:drawable="#color/orange"/>
<item
android:state_enabled="false"
android:drawable="#color/default"/>
<item
android:drawable="#color/default"/>
</selector>
Updated:
so you save this files as : btn_drawable.xml in drawable folder.
Simply replace ?android:attr/selectableItemBackground
with *#drawable/btn_drawable.xml*
Thanks #Nimish-Choudhary ...! I followed your advice. and I have explained it further for clarity to all having same question as me as a beginner.
Create an xml with name say "btntransparent.xml"
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true">
<item
android:state_pressed="true"
android:drawable="#color/pressed"/>
<item
android:state_enabled="false"
android:drawable="#color/defaultColor"/>
<item
android:drawable="#color/defaultColor"/>
</selector>
Next add the colors "pressed" and "defaultColor" to another xml say "colors.xml"
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="pressed">#CCFF8800</color>
<color name="defaultColor">#00000000</color>
</resources>
Here "#CCFF8800" is my pressed state Translucent Orange and "#00000000" is the 100% Transparent Black (;-) thats invisible). You can find more about color codes at Color| Android Developers
Now put the "colors.xml" in values Folder and "btntransparent.xml" in drawable Folder.
Now the last step is to voila use it in the button as
<Button
android:id="#+id/id_btn_skip"
android:background="#drawable/transparentbtn"
android:onClick="skipToMain"
android:text="#string/btn_skip" />
And thats should do the job...!
Take care.
regards,
raisedadead
If I understand you correctly, what you could do is add new resource in #drawable for example my_ripple.xml
<?xml version="0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#FF8800">
</ripple>
Then simply set this as your background.
In your theme add the following:
<item name="android:selectableItemBackground">#FF8800</item>
to override the default blue.

Resources