Background image in TabBar Android - android

I'm trying set the background image for a tabbar in my app like in this example,
Android Design in Action: Transit Apps in the minute 27:16
My code is:
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarTabBarStyle">#style/Divider</item>
<!-- Customize your theme here. -->
</style>
<style name="Divider" parent="#android:style/Widget.Holo.ActionBar.TabBar">
<item name="android:background">#drawable/ic_launcher</item>
</style>
but the picture is stretched
How do I can get the same thing ?
Regards,
racso

Related

How can I use dynamic colors in SplashScreen api an android 12?

I'm trying to make the background of an android 12 splash screen use #android:color/system_neutral1_900 as the background, but as I can see, the color loads only after the splash screen. Is there any way to use it on the splash screen?
<style name="Theme.App.SplashScreen" parent="Theme.SplashScreen">
<!-- Set the splash screen background, animated icon, and animation duration. -->
<item name="windowSplashScreenBackground">#android:color/system_neutral1_900</item>
</style>
The color does not appear and it uses the default grey. I also tried with other system_ colors and the same result comes up. Using #android:color/black or hex colors works.
Try using this item as part of your main application theme according to this link
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowSplashScreenBackground">#color/colorAccent</item>
</style>

Xamarin.Forms - Android - Change three dots or ellipsis icon in ContentPage.ToolbarItems

I have used the <ContentPage.ToolbarItems> in my code ti display a menu on the top right of the app. My app is only targeting Android at the moment even though it's written in Xamarin.Forms.
I am struggling to change the three dots icon. Any idea how I can achieve that either using Custom Renderer, Effects or styles.xml?
I have seen answers on this overflow but they are all referring to native android and I am struggling to understand how I can do it on Xamarin.Forms.
Thanks!
You can modify style.xml to achieve that .No mattter in forms or native , this will work .
Add item inside MainTheme.Base :
<item name="actionOverflowButtonStyle">#style/OverflowButtonStyle</item>
Then adding style inside resourses :
<style name="OverflowButtonStyle" parent="#android:style/Widget.ActionButton.Overflow">
<item name="android:src">#drawable/circle</item> //here set the wanted icon
</style>
The full style.xml is :
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from https://aka.ms/material-colors -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF4081</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="actionOverflowButtonStyle">#style/OverflowButtonStyle</item>
<item name="android:datePickerDialogTheme">#style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
<style name="OverflowButtonStyle" parent="#android:style/Widget.ActionButton.Overflow">
<item name="android:src">#drawable/circle</item>
</style>
</resources>
The effect :

Make all views transparent to see only theme background image

I saw a lot of modern beautiful apps in the Play Store that use image as background. I decided to use this solution in my application. I develop for minimum API 21 Android 5.0. I prepared image 1920x1080 for xxhdpi Nexus 5 AVD.
I use material light theme. Here is my modified theme definition xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:background">#drawable/parquet</item>
<item name="android:actionBarStyle">#style/transparentActionBar</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="transparentActionBar" parent="android:Widget.Material.Light.ActionBar">
<item name="android:background">#android:color/transparent</item>
</style>
When I run application I see that each view uses its own scaled copy of theme image. My custom defined style 'transparentActionBar' has no effect on action bar. Only behind status bar I see something like original image. Is it possible to define all views transparency via XML to make visible only screen background image? If no, tell please what is right approach to the solution of this problem.
Regards.
This code does exact what I want
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowBackground">#drawable/parquet</item>
<item name="android:actionBarStyle">#style/ActionBarStyle.Transparent</item>
</style>
<style name="ActionBarStyle.Transparent" parent="android:Widget.Material.Light.ActionBar">
<item name="android:background">#null</item>
</style>

Textview background color got changed after adding custom theme to android app

My app interface originally looked like this. "my name" is a TextView and "my button" is a button which has an image as the background. Minimum sdk is 16.
I changed the action bar color of the app by adding a custom theme. I used the code below.
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyTheme</item>
<!-- Customize your theme here. -->
</style>
<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">#color/com_facebook_blue</item>
</style>
Then my output came like this.
All the background color got changed to the new color of the app. I only need to change the color of the action bar.
Can anyone help me?
Try this
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>

Testing ActionBar Background Color

I am starting to unit testing my Android code. However, I am facing a problem of how to test the background of ActionBar. I set the action bar color using the following:
<style name="AppBaseTheme" parent="android:Theme.Light">
<item name="android:actionBarStyle">#style/ActionBarTheme</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="ActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/dark_green</item>
</style>
So, how to load the style in code and check for the background color so I can test it?
In your application manifest make sure you have android:theme="#style/AppBaseTheme"
Or whatever you decide to name your custom theme.

Categories

Resources