AndroidManifest select style defined in manifest resources

Viewed 57

Im using Delphi to develop wear os application. I want set android:windowSwipeToDismiss to false but in Delphi I can modify only Android manifest, cant change style (or i dont know how) So i want do somthing like that

<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="%package%"
    android:versionCode="%versionCode%"
    android:versionName="%versionName%"
    android:installLocation="%installLocation%">
    <uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="%targetSdkVersion%" />
<%uses-permission%>
    <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
    
    <queries>
<%queries-child-elements%>
    </queries>

      <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:persistent="%persistent%"
        android:restoreAnyVersion="%restoreAnyVersion%"
        android:label="%label%"
        android:debuggable="%debuggable%"
        android:largeHeap="%largeHeap%"
        android:icon="%icon%"
        android:theme="%theme%"
        android:hardwareAccelerated="%hardwareAccelerated%"
        android:resizeableActivity="false"
        android:requestLegacyExternalStorage="true"
        android:usesCleartextTraffic="true">
<%provider%>
<%application-meta-data%>
<%uses-libraries%>
<%services%>
        <!-- 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="%activityLabel%"
               android:theme="@manifest/Themeabc"
            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="%libNameValue%" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
<%activity%>
<%receivers%>
<resources>
  <style name="Themeabc" parent="@android:style/Theme.DeviceDefault.Light">
      <item name="android:windowSwipeToDismiss">false</item>
  </style>
</resources>
    </application>
</manifest>

but have problem here :

       android:theme="@manifest/Themeabc"

i getting error: C:\path\AndroidManifest.xml:51: error: Error: No resource found that matches the given name (at 'theme' with value '@manifest/Themeabc').

maybe write "@manifest/Themeabc" in other words help? but i dont know how this android .xml works exacly

Can I define style local and use it like in html?

I tried @AndroidManifest/Themeabc, @manifest/Themeabc.

1 Answers

The problem appears to be the "@manifest" resource type that you specified.

According to the documentation, Android resources (such as styles, drawables, strings, ...) are expressed as values with the following format (it's a Java annotation) : @[package:]type/name

The package name here can be omitted if the resource is provided by your app (including if it is provided by a library dependency, because library resources are merged into your app resources). The only other valid package name is "android", when you want to use a resource from the Android framework.

The type here is the type of resource, such as "string" or "drawable" (and not the file where it is declared as you mentionned "manifest"). And the name is the name that identifies the specific resource. Here is an example :

<activity android:icon="@drawable/smallPic" ... >

And for styles (and themes), the default annotation is : @[package:]style/style_name

Declared as followed in the resources XML file of your app :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="style_name" parent="@[package:]style/style_to_inherit">
      <item name="[package:]style_property_name">style_value</item>
    </style>
</resources>

And when using that style/theme in an activity within the "Android manifest", here is how it would be :

<manifest ... >
    <application ... >
        <activity android:theme="@style/Theme.AppCompat.Light" ... >
        </activity>
    </application>
</manifest>

You have to set correctly the type of your resource.


Also, if setting the resource type didn't solve your problem, then you should move the style declaration from the Android manifest to an independent XML resource file in the "res/value" folder.

This XML file can be used either only for styles or for combining other android simple resources under one <resources> node. Because the style is referenced using the value provided in the "name" attribute (not the name of the XML file).

The file location must be "res/values/filename.xml" where the filename is arbitrary. The element's name will be used as the resource ID.

In Delphi, you have to create this XML file and add it in the deployment manager and set its distant file property as "res/value/filename.xml"

You can get further informations about Android API by checking these links :

Related