I'm new to Mono for Android (using MonoDevelop) and Android development in general. I want to create a application wide theme. This theme only has to set the background color of all EditText fields gray (just to test the functionality).
In the Resources/values folder I created 2 files:
Styles.xml
<resources>
<style name="tstEditText" parent="android:style/Widget.EditText">
<item name="android:background">#cccccc</item>
</style>
</resources>
Themes.xml
<resources>
<style name="MyApplicationTheme" parent="android:Theme">
<item name="android:editTextStyle">#style/txtEditText</item>
</style>
</resources>
After that I modified the ApplicationManifest.xml
<application android:label="MyApplication" android:theme="MyApplicationTheme"></application>
When I try to build the code I get the following error message: "Error: String types not allowed (at 'theme' with value 'MyApplicationTheme')." The error is thrown on the first activity node in the AndroidManifest.xml that is generated on build by MonoDevelop.
Apparently I'm missing something, but I have no clue...
Thanks in advance for your help!
In the manifest XML you need to specify the theme like this:
android:theme="#style/MyApplicationTheme"
Related
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)
Is there a way to reuse styles in an iOS app as it's done in android?
(or other approach, css-like, for example)
Like this:
styles.xml
<style name="SplashTheme" parent="#style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#android:color/black</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#color/AppBackground</item>
</style>
<!-- Search Bar -->
<style name="AppTheme.SearchBar" parent="AppTheme">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">#dimen/searchBarSize</item>
<item name="android:background">#drawable/search_bar_background</item>
<item name="android:layout_alignParentTop">true</item>
<item name="android:layout_alignParentLeft">true</item>
</style>
//...
activity.xml
<LinearLayout
android:layout_below="#id/searchBar"
style="#style/AppTheme.Table"
>
//...
</LinearLayout>
There are several libraries which you should take a look at including Freestyle (http://www.freestyle.org), UISS (https://github.com/robertwijas/UISS), NUI (https://github.com/tombenner/nui) and MAThemeKit (https://github.com/mamaral/MAThemeKit).
Also check out the documentation for UIAppearance.
Short answer: no.
Long answer: You will either need to manually set the styles on each view, OR you could extend the components (or create your own subclasses) which implements the styles you want.
I am trying to open an external link from my menu-config.xml submenu..Is this possible to do ?
It is not working for me
<Menu name="MainMenu" title="MainMenu" description="MainMenu">
<Item name="Google" title="Google" description="Google" link="http://www.google.com" ></Item>
<Item name="Google" title="Google" description="Google" link="http://www.google.com" ></Item>
</Menu>
I tried using location and like this
menu name="google" link="javascript:window.open('http://www.google.com/');"
Thanks
Am publishing an app for iPad with Flash cc, air 4.0.
Problem: I need to include 2 high-res icons, 76x76 and 152x152.
But, nowhere on the Flash publish settings (under the icons tab) do I see a way to add those files. Still, Apple is giving me hassle about them.
Does anyone know how to add those extra icons, what to name them, where to put them so that when they are bundled in the IPA, they are included?
Thanks!!
This is my descriptor file ("cannot be parsed" error): Maybe I'm putting the two new icons in the wrong place in my code?? This is the whole descriptor file:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<application xmlns="http://ns.adobe.com/air/application/4.0">
<id>com.theapptrain.tpvision</id>
<versionNumber>1.0</versionNumber>
<filename>Hospitality TV</filename>
<description></description>
<!-- To localize the description, use the following format for the description element.
<description>
<text xml:lang="en">English App description goes here</text>
<text xml:lang="fr">French App description goes here</text>
<text xml:lang="ja">Japanese App description goes here</text>
</description>
-->
<name>Hospitality TV</name>
<!-- To localize the name, use the following format for the name element.
<name>
<text xml:lang="en">English App name goes here</text>
<text xml:lang="fr">French App name goes here</text>
<text xml:lang="ja">Japanese App name goes here</text>
</name>
-->
<copyright></copyright>
<initialWindow>
<content>TPVisionApp.swf</content>
<systemChrome>standard</systemChrome>
<transparent>false</transparent>
<visible>true</visible>
<fullScreen>true</fullScreen>
<autoOrients>false</autoOrients>
<aspectRatio>landscape</aspectRatio>
<renderMode>auto</renderMode>
</initialWindow>
<customUpdateUI>false</customUpdateUI>
<allowBrowserInvocation>false</allowBrowserInvocation>
<icon>
<image29x29>icons/tpvision29x29.png</image29x29>
<image57x57>icons/tpvision57x57.png</image57x57>
<image114x114>icons/tpvision114x114.png</image114x114>
<image512x512>icons/tpvision512x512.png</image512x512>
<image48x48>icons/tpvision48x48.png</image48x48>
<image72x72>icons/tpvision72x72.png</image72x72>
<image76x76>icons/tpvision76x76.png</image76x76>
<image50x50>icons/tpvision50x50.png</image50x50>
<image58x58>icons/tpvision58x58.png</image58x58>
<image100x100>icons/tpvision100x100.png</image100x100>
<image144x144>icons/tpvision144x144.png</image144x144>
<image152x152>icons/tpvision152x152.png</image152x152>
<image1024x1024>icons/tpvision1024x1024.png</image1024x1024>
</icon>
<supportedLanguages>en</supportedLanguages>
<iPhone>
<requestedDisplayResolution>high</requestedDisplayResolution>
<InfoAdditions><![CDATA[
<key>UIDeviceFamily</key>
<array><string>2</string></array>
]]></InfoAdditions>
</iPhone>
<version>1.0</version>
</application>
You might want to take a look here: http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac1e63e3d129907d2886-8000.htmlI used to build my apps via flash too and I always entered the icons in the application description file as described on the linked site.
Am trying to implement internationalization support to my project for this people suggested google Closure Templates.but am very new to closure templates.am trying to get the language specific messages using closure template but am not getting in xlf file.If any one knows how to generate language specific messages using closure template, please tell me the steps.that's great help to me.
My .soy file code as bellow.
{namespace poc}
/**
*Testing message translation
*#param pageTitle
*/
{template .translate}
<HTML>
<Head>
<title>{$pageTitle}
</title>
</head>
<div>
{msg desc="Hello"}Hello{/msg}
</div>
</html>
{/template}
and generated .xlf content as bellow
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file original="SoyMsgBundle" datatype="x-soy-msg-bundle" xml:space="preserve" source-language="en" target-language="pt-BR">
<body>
<trans-unit id="2286494898080570401" datatype="html">
<source>Thanks</source>
<target/>
<note priority="1" from="description">Says thanks</note>
</trans-unit>
</body>
</file>
</xliff>
I see you already used the SoyMsgExtractor to create the base xlf. Next you need to make translations of this base xlf to the languages you want to support. A file for each language is created. I used the xliff exitor from Translution. http://sourceforge.net/projects/eviltrans.
Next, using the SoyToJsSrcCompiler a translation soy can be made per language:
java -jar SoyToJsSrcCompiler.jar --shouldGenerateGoogMsgDefs --bidiGlobalDir 1 --messageFilePathFormat Filename_en-us.xliff --outputPathFormat FileName_fr.js *.soy
This will create a Filename._fr.js file that contains the compiled soy file.
Including this file instead of the original soy (or compiled) will create a localized version.
Good luck!
\Rene
i think the easiest way is to make (i.e. generate from whatever source) a separate js file which contains one messages object and reference it through an extern declared function.
it justs works and has no complicated dependencies.