How to hide the "Title Bar" using Xamarin - xamarin

I have 4 different activities on my app, in 2 of them it shows a white Title bar (with activity or package name) above my custom toolbar, but in other 2 this bar is hidden by the custom one.
I want to show only my custom toolbar and hide the default...
this is my "styles.xml" code:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:colorPrimary">#color/primaryColor</item>
<item name="android:colorPrimaryDark">#color/primaryDarkColor</item>
<item name="android:colorAccent">#color/secondaryColor</item>
<item name ="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
</style>
<style name="MyActionBar" parent="#android:style/Theme.Holo.NoActionBar">
<item name="android:background">#color/primaryColor</item>
<item name="android:textColor">#color/primaryTextColor</item>
</style>
</resources>

[Solved]
I just change the class my Activities was inheriting from AppCompatActivity to FragmentActivity (until now I have no issues came from this change)

Related

How to remove space from the top of a splash screen in Xamarin.Forms?

I'm working on an application with Xamarin.Forms in Visual Studio 2019, I already have the splash screen but when I run it it doesn't cover the entire screen, it leaves a space where the notification bar should go, I already tried with the "NoTileBar" property and it did, but when opening it from the smartphone does not make the change. Could you help me change it?
Styles.xml
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
enter image description here
styles.xml
<style name="MainTheme.Splash" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
Check your MainActivity Flags as shown below
Add SplshActivity class
[Activity(Theme = "#style/MainTheme.Splash",
MainLauncher = true,
NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
// Launches the startup task
protected override void OnResume()
{
base.OnResume();
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
}
}
At first, if you want to hide the action bar in your activity, you need to change the <item name="android:windowActionBar">true</item> to <item name="android:windowActionBar">false</item>.
And then does the notification bar mean the system's status bar? If so you can try to use the following code to hide it:
WindowInsetsControllerCompat windowInsetsController =
ViewCompat.getWindowInsetsController(WindowDecorView);
windowInsetsController.hide(WindowInsetsCompat.Type.statusBars());
For more infromation, you can check the official document about hiding the system bars.

android:windowBackground property makes background black (Xamarin.Android)

I want to make the following image to be the background for the entire Xamarin.Android application:
I reference the image in Base application theme in styles.xml :
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
.....
<item name="android:windowBackground">#drawable/ic_app_background_image</item>
.....
</style>
The background applies to all the application but the image has dark background:
Also the number 51 has some strange things around it.
When I set the android:background="#drawable/ic_app_background_image" to the most outer LinearLayout of an activity it works fine, it shows the screen like that:
How can I fix the android:windowBackground property setting the background to black issue so I don't have to put android:background="#drawable/ic_app_background_image" in the LinearLayout of every activity?
You can try following method:
1.Create new file name as bg.xml in drawable folder (bg.xml)
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#color/splash_background"/>
</item>
<item>
<bitmap
android:src="#drawable/splash_logo"
android:tileMode="disabled"
android:gravity="center"/>
</item>
</layer-list>
2.define background color in colors.xml
<color name="window_background">#F5F5F5</color>
<color name="splash_background">#FFFFFF</color>
3.define new style MyTheme.Splash in style.xml and use the bg in item android:windowBackground
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/bg</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
4.Usage in Activity
[Activity(Theme = "#style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
// other code
}
Update:
If you want to apply this style to all activities, you can just add the following code to your Base application theme. And we don't need to set for each activity. For example:
<!-- Base application theme. parent="Theme.AppCompat.Light.DarkActionBar" -->
<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>
<item name="android:windowBackground">#drawable/bg</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
The result is:
For more details, you can check: https://learn.microsoft.com/en-us/xamarin/android/user-interface/splash-screen

how to change the status bar color to transparent for splash screen using nativescript?

enter image description hereHow to change the status bar icon color for splash screen (LaunchScreenTheme) in android ?
I tried the below code but it's not working .
<color name="ns_ThemeBase">#FFFFFF</color>
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
<item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="colorPrimaryDark">#color/ns_ThemeBase</item>
</style>
How to change the status bar background to white and the icons to black ?
If it helps, I wasn't able to make status bar transparent, my workaround is to hide it.
Try to add those two lines in your style :
<item name="android:windowFullscreen">true</item>
<item name="windowActionBar">false</item>
You should have this (styles.xml) :
<!-- Launch Screen -->
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
<item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="colorPrimaryDark">#color/ns_ThemeBase</item>
<item name="android:windowFullscreen">true</item>
<item name="windowActionBar">false</item>
</style>
Working example : https://github.com/mickaeleuranie/nativescript-stackoverflow-49236235
How it looks :
enter image description here
This is what i actually looked for and i achieved it by using the code
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
<item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowLightStatusBar">true</item>
<item name="colorPrimaryDark">#color/ns_ThemeBase</item>
</style>
Thanks for all your support , Cheers :)

How to change action bar title color when i am using theme "android:theme="#style/android:Theme.Holo.Light"

How to change action bar title color when i am using theme android:theme="#style/android:Theme.Holo.Light in mono.android.
In your styles
<style name="CustomThemeActionBar" parent="#style/android:Theme.Holo.Light">
<item name="android:background">#color/blue</item>
<item name="android:titleTextStyle">#style/CustomThemeActionBarTitleTextStyle</item>
<style name="CustomThemeActionBarTitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textStyle" >bold</item>
<item name="android:gravity">center</item>
This is how i was able to change the colour of the text in the action bar

How to change the Clear Icon in SearchView of Actionbar

I used the appcompat to implemented the actionbar, now I want to change the clear icon. And I have done this:
<item android:id="#+id/action_search_note"
android:title="#string/search_title"
android:orderInCategory="101"
android:icon="#drawable/ic_action_search"
snailnote:showAsAction="collapseActionView|ifRoom"
snailnote:actionViewClass="android.support.v7.widget.SearchView" />
my team:
<item name="searchViewCloseIcon">#drawable/search_clear_normal</item>
I also tried to add
<item name="android:searchViewCloseIcon">#drawable/search_clear_normal</item>
but it is giving an error, and I final removed it.
But it dosen't work, how should I change the clear icon in a right way.
<style name="AppTheme" parent="#style/Theme.Base.AppCompat.Light.DarkActionBar">
<item name="actionBarWidgetTheme">#style/YourActionBarWidget</item>
</style>
<style name="YourActionBarWidget" parent="#style/Theme.AppCompat">
<item name="searchViewCloseIcon">#drawable/xxx</item>
</style>
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
<item name="closeIcon">#drawable/search_clear_normal </item>
</style>

Resources