We've been upgrading our application to Xamarin.Forms 5 and it's unclear how to correctly set the AppCompat theme now that we've migrated to the AndroidX package. When using
<style name="MyTheme.ActionBarAppCompat" parent="#android:style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>
I get error APT2260: resource android:style/Theme.AppCompat.Light.DarkActionBar not found.
If I remove the android: the application compiles, but the navigation bar overlaps controls on the page.
I couldn't see the full code of your styles.xml, but I tried to create a simple xamarin android app with the latest vertion of nuget Xamarin.Androidx.AppCompat.
The default code of file styles.xml is:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.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:windowDrawsSystemBarBackgrounds">true</item>
</style>
Note:You can compare it to your code. If the problem still exists after correction, you can post the code of your styles.xml here.
Related
I have a master-detail page in my project and added some content pages into it as the children. How I can change the color of the top bar of the child content page? I have added some icons on the top bar using <NavigationPage.TitleView>.
I need to change the red square background color. Already I tried the solution preferred here, but that not solves my problem.
In order to change that Navigation bar's background color for Android follow the following steps:
Go to your Android Project -> Resources -> values -> styles.xml
Open style.xaml file update colorPrimary value with your required hex color code
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#3478c9</item>
For iOS this can be controlled from App.xaml file, no need to write anything in iOS project
<Application.Resources>
<ResourceDictionary>
<!-- Styles -->
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="#3478c9"/>
<Setter Property="BarTextColor" Value="White"/>
</Style>
<!-- Styles -->
</ResourceDictionary>
</Application.Resources>
I know that for whatever reason google decided to make all button text capitalised in lollipop.
How do I set it in my appcelerator app that all my button text is not uppercase, but just however I typed it?
All you need is to define a android values under
/app/platform/android/res/values.xml
<resources>
<style name="Theme.myTheme" parent="#style/Theme.AppCompat.NoActionBar">
<item name="android:buttonStyle">#style/customButton</item>
</style>
<style name="customButton" parent="Widget.AppCompat.Button">
<item name="android:textAllCaps">false</item>
</style>
Add android theme to manifest (Theme.myTheme):
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<supports-screens android:anyDensity="false"
android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23"/>
<application android:debuggable="true"
android:icon="#drawable/appicon"
android:largeHeap="true" android:theme="#style/Theme.myTheme">
<activity
android:configChanges="keyboardHidden|orientation|screenSize" android:name="org.appcelerator.titanium.TiActivity"/>
</application>
</manifest>
</android>
Why do you need to use a button and depend on the system's default layout?
You could just use a View instead and listen to the click event.
You could style the view as you wish and it would look the same across different platforms.
I am using Xamarin forms, but I want to make navigation-bar back button only for android project. I simply want make it bigger and change color of it. What would be the best way to do it? Thank you for any answers or suggestions.
As #Rohit mentioned you will need a to customize the action bar inside the styles.xml which is inside the values folder inside the Resourses folder of your android project, James Montemagno did a blog post related to that when he introduce the FormsAppCompatActivity an example of a cuztom nav bar would be like this:
<style name="AppMainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#0063a4</item>
<item name="colorPrimaryDark">#003A63</item>
<item name="colorAccent">#86c447</item>
<item name="android:windowBackground">#color/AppBackgroundColor</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">#style/AppCompatDialogStyle</item>
</style>
And the blog post is here: https://blog.xamarin.com/android-tips-hello-toolbar-goodbye-action-bar/
In regards of navigation bar height it may involved more cuztomization and a custom view inside the Navigation Bar, here is an android example:
https://guides.codepath.com/android/Using-the-App-ToolBar
I'm currently working on a Xamarin.Forms application and am specifically applying styles. I've seen examples of global styles placed in the App.xaml file of the desired platform project and was under the impression that you could reference the globally declared styles with a DynamicResourcereference such as below:
in UWP App.xaml
<Application
<Application.Resources>
<ResourceDictionary>
<Style x:Key="myLabel" TargetType="TextBlock">
<Setter Property="Foreground" Value="Purple" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
Then in Login.xaml in the Portable Project
<Label Text="hey hey im purple" Style="{DynamicResource myLabel}" />
I'm under the impression that this text should be purple, however it is not. I can style the Label using a ResourceDictionary defined within the page that it is used, however I cannot use it in global.
The interesting thing is that if I declare an implicit global style, it works:
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Purple" />
</Style>
It's when I try explicit global styles with x:Key="myVariable" that it doesnt work.
tldr; global explicit styles are not working for me (but global implicit styles are working)
Any ideas Stack Community? Thanks!
You should define this in your common project's app.xaml instead of define this in UWP app.xaml.
I see that works by myself.
I got EASTL from here - https://github.com/paulhodge/EASTL
For debugging, I'm writing custom visualizer VS2012/2013.
"eastl::vector" works fine but "eastl::map" doesn't.
Here is my code
<Type Name="eastl::map<*>">
<DisplayString>{{size = {mnSize}}}</DisplayString>
<Expand>
<Item Name="[size]">mnSize</Item>
<Item Name="[comp]">mCompare</Item>
<TreeItems>
<Size>mnSize</Size>
<HeadPointer>mAnchor.mpNodeParent</HeadPointer>
<LeftPointer>mpNodeLeft</LeftPointer>
<RightPointer>mpNodeRight</RightPointer>
<ValueNode>(node_type*)this->mValue</ValueNode>
</TreeItems>
</Expand>
</Type>
It looks like VS doesn't recognize "node_type"
Thanks for responding.
I had the same problem for EASTL.
It turned out that I was using an old version of EASTL.natvis. This one works for me: https://github.com/electronicarts/EASTL/blob/master/doc/EASTL.natvis
The file you have to replace is in:
%userprofile%\Documents\Visual Studio 2015\Visualizers
(Just change 2015 to whatever version of VS you are using)