I change the manifest file to use the following theme:
change from:
#style/AppTheme
to
#style/Theme.Material.Light
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="App1.App1" android:installLocation="preferExternal">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:roundIcon="#mipmap/ic_launcher_round" android:supportsRtl="true" **android:theme="#style/Theme.Material.Light"></application>
</manifest>
But when building and deploying got the following error:
Sdkminversion is as follows it is above 21.
uses-sdk android:minSdkVersion="23"
i have managed to make it able to compile using Theme.Holo.Light
however,the theme is still black in color by clearing the content in the following folder:
C:\Users\your_name\AppData\Local\Xamarin
Theme.Holo.Light is supposed to be white in colour background ,right?
Any idea what is wrong?
You should define Theme.Material.Light in your /Resource/values/style.xml.
<style name="MyMaterialTheme" parent="Theme.Material.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#1286d9</item>
<item name="colorPrimaryDark">#1286d9</item>
</style>
& than use it like this #style/MyMaterialTheme. You should use color and other features according to your preference.
😊
Related
I tried to add a BroadcastReciever to the Android part of my Xamarin app to help with notifications, but if I try to register it in the manifest, I get the build error in the title of this question. I don't want to use code attributes because then it won't work if the app isn't running according to Microsoft's documentation (I don't remember which page).
Here is my (unmerged) manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.partylist" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="Partylist.Android">
<reciever android:name=".AlarmReciever" android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</reciever>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECIEVE_BOOT_COMPLETED" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
</manifest>
Also, the line that the error says it's on is actually the line where I have the intent filter inside the BroadcastReciever, not the BroadcastReciever itself.
Watch out for spelling typos, It should be <receiver> from BroadcastReceiver.
I would like to remove the purple gap in my preference screen:
preference
so that it should look like this:
Google Play Store example
I'm using Xamarin Android and c# to develop my app.
The preference screen is an PreferenceFragmentCompat from Android.Support.V7.Preferences library. The material style is set in my custom theme:
<style name="Theme.DarkTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">#673AB7</item>
<item name="colorPrimaryDark">#512DA8</item>
<item name="colorAccent">#039be5</item><!--#FF4081-->
<item name="colorControlHighlight">#242424</item>
<item name="android:listDivider">#style/android:drawable/divider_horizontal_dim_dark</item>
<item name="preferenceTheme">#style/PreferenceThemeOverlay.v14.Material</item>
Here is how my xml resource file looks like, which I call by AddPreferencesFromResource(Resources.Id.preference_screen) in my PreferenceFragmentCompats OnCreatePreferences() function:
<android.support.v7.preference.PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.preference.PreferenceCategory
android:title="App">
<Preference
android:key="advsettings_preference"
android:title="Erweiterte Einstellungen" />
<Preference
android:key="license_preference"
android:title="Rechtliche Hinweise" />
</android.support.v7.preference.PreferenceCategory>
</android.support.v7.preference.PreferenceScreen>
I already tried to fix it myself by adding padding attributes to PreferenceScreen, but nothing changed.
All the latest NuGet Packages from Xamarin Android are installed (v27.0.2).
Thanks in advance.
Please try set the style like this;
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<!-- Customize your theme here. -->
<item name="preferenceTheme">#style/MyPreferenceStyle</item>
</style>
<style name="MyPreferenceStyle" parent="#style/PreferenceThemeOverlay.v14.Material">
<item name="preferenceCategoryStyle">#style/MyPreferenceCategoryStyle</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:paddingRight">10dp</item>
</style>
<style name="MyPreferenceCategoryStyle" parent="#style/Preference.Category.Material">
<item name="android:layout">#layout/preference_category</item>
</style>
And preference_category.axml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+android:id/title"
android:textColor="?android:attr/colorAccent"
android:textSize="14dp"
android:fontFamily="sans-serif-medium"
android:paddingStart="16dp"
android:singleLine="true"
android:paddingTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
And AppSettings:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.preference.PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.preference.PreferenceCategory
android:title="App">
<Preference
android:key="advsettings_preference"
android:title="Erweiterte Einstellungen"
android:summary="BenachRichtigung"/>
</android.support.v7.preference.PreferenceCategory>
</android.support.v7.preference.PreferenceScreen>
It will resolve the gap issue. And also look similar to your screenshot of Google Play Store. Well, not exactly the same from the Layout Inspector, but similar:
The purple area when looking at your layout with "use layout bounds" in the developer options enabled represent margins, not padding as far as I know.
I suggest trying to make a custom layout for your PreferenceCategory and your Preference's and setting them in your above axml using the android:layout attribute as such:
android:layout="#layout/layout_name"
(Might need to play around with both android:layout and android:widgetLayout attributes)
I am getting Binary XML file line #1: Binary XML file line #1: Error inflating class error occure for AppCompat error while trying to add tabbar and toolbar in android.Can anybody help me to come out of it.refering this link AppCompact
Here is my code. This is Style`
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light">
<item name="android:windowBackground">#drawable/Splash</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primaryDark</item>
<item name="colorAccent">#color/accent</item>
<item name="android:windowBackground">#color/window_background</item>
<item name="windowActionModeOverlay">true</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
</resources>
This is code in Tabbar.axml and toolbar.axml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabIndicatorColor="#android:color/white"
app:tabGravity="fill"
app:tabMode="fixed" />
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
and main activity
public class FormsActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity//FormsApplicationActivity//
{ protected override void OnCreate (Bundle savedInstanceState)
{
FormsAppCompatActivity.ToolbarResource = Resource.Layout.Toolbar;
FormsAppCompatActivity.TabLayoutResource = Resource.Layout.Tabbar;
base.OnCreate (savedInstanceState);}
`
Try to uninstall the Xamarin.Forms, do a full clean, delete bin/obj folder, restart VS, install back the Xamarin.Forms, rebuild whole solution.
I am trying to implement GCM without BAAS in GCM. I have looked at previous examples using the bridge and from my research the following should work without relying on the old TGCMReceiver component.
But the following line always returns nil, I run this after the application starts up on a button click:
APushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM);
APushService is always nil.
My AndroidManifest looks as follows:
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.embarcadero.Project1"
android:versionCode="1"
android:versionName="1.0.0"
android:installLocation="auto">
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<permission android:name="com.embarcadero.Project1.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.embarcadero.Project1.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:glEsVersion="0x00020000" android:required="True"/>
<application android:persistent="False"
android:restoreAnyVersion="False"
android:label="Project1"
android:debuggable="True"
android:largeHeap="False"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true">
<meta-data android:name="com.google.android.gms.version" android:value="4323000" />
<!-- Our activity is a subclass of the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
android:label="Project1"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:launchMode="singleTask">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="Project1" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<receiver
android:name="com.embarcadero.gcm.notifications.GCMNotification" android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.embarcadero.Project1" />
</intent-filter>
</receiver>
<receiver android:name="com.embarcadero.rtl.notifications.NotificationAlarm" />
<receiver android:exported="true" android:name="com.embarcadero.gcm.notifications.GCMNotification" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.embarcadero.Project1" />
</intent-filter>
</receiver>
<service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->
I have tried using the common TGCMReceiver application that is out there from CodeRage9 using XE8, it doesn't work in XE10 / Seattle and it does appear that XE10 is updated in this regard but I cannot make anything work with simple Google Cloud Messaging and am looking for some guidance.
The answer is shown here: Issue with GCM Push notification service DELPHI XE6
Except with .Active := True not AutoActivate := True as indicated by the Answer.
TL;DR version. Drop TKinvyProvider on form with just the GCMAppID populated, Drop TPushEvent on Form with AutoRegister and AutoActivate set to false. In entitlement list set "support push notification : true".. add in the following to your AndroidManifest.template.xml:
<service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
Right before </application>.
I'm trying to add Google Maps v2 to an Mvx project by combining the Monodroid MapsAndLocationDemo_v2 with the N=26 Fraggle demo from NPlus1DaysOfMvvmCross.
I have added Google Play services to the Maps demo and am successfully displaying a map using:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
With the Fraggle demo, the same fragment causes an Android.Views.InflateException error.
I have followed the same steps to add Google Play services to both projects, and am using the same AndroidManifest.xml file in both projects
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.demo.app" android:installLocation="auto" android:versionCode="1" android:versionName="1">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<application android:label="Demo"></application>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.demo.app.permission.MAPS_RECEIVE" />
<permission android:name="com.demo.app.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AAAAAAAAAAAAAAAAA-xxxxxxxxxxxxxxxxxxxxxx" />
</manifest>
Other than adding the fragment and updating the manifest, there are no changes to the Fraggle demo code. The working view from the Maps demo is
namespace SimpleMapDemo
{
using Android.App;
using Android.OS;
using Android.Support.V4.App;
[Activity(Label = "#string/basic_map")]
public class BasicDemoActivity : FragmentActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.BasicDemo);
}
}
}
and the view from the Mvx version is:
using Android.App;
using Android.OS;
using Cirrious.MvvmCross.Droid.Fragging;
using Rock.Core.ViewModels;
namespace Rock.Droid.Views
{
[Activity(Label = "View for FirstViewModel")]
public class FirstView : MvxFragmentActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.FirstView);
}
}
}
I've also tried referencing the Google Play services dll from the working demo, and have the same results.
Ah. It was a mistake in the AndroidManifest.xml file. The Maps API Key needs to be inside the application node. If it's not there, it causes an exception.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.demo.app" android:installLocation="auto" android:versionCode="1" android:versionName="1">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<application android:label="Demo">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AAAAAAAAAAAAAAAAA-xxxxxxxxxxxxxxxxxxxxxx" />
</application>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.demo.app.permission.MAPS_RECEIVE" />
<permission android:name="com.demo.app.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
</manifest>