[英]How to get Holo Light theme working in my Xamarin application
I'm trying to get my app to use the Holo.Light theme. 我正在尝试让我的应用程序使用Holo.Light主题。 I've created a custom theme for Holo and put it in 我为Holo创建了一个自定义主题并将其放入
Resourses\\values-v11\\FsmTheme.xml 资源的开发\\值-V11 \\ FsmTheme.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="FsmTheme" parent="@android:style/Theme.Holo.Light">
</style>
</resources>
I've also created one for older versions and put it in 我还为旧版本创建了一个并将其放入
Resourses\\values\\FsmTheme.xml 资源的开发\\值\\ FsmTheme.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="FsmTheme" parent="@android:style/Theme.Light.NoTitleBar">
</style>
</resources>
Then I added it to my AndroidManifest.xml
然后我将它添加到我的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="001" android:versionName="001" package="futurestate.app.droid">
<uses-sdk android:minSdkVersion="12" android:targetSdkVersion="14" />
<application android:label="FutureState App Demo" android:icon="@drawable/Icon" Theme="@style/FsmTheme" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
I'm not sure what else I would need to do to get the theme to take in the app. 我不确定我还需要做些什么才能让主题在应用程序中占据一席之地。
You can use Attributes to modify values in the AndroidManifest.xml, for example this changes the theme to holo light: 您可以使用属性修改AndroidManifest.xml中的值,例如,这会将主题更改为holo light:
[Activity(
Label = "Foobar",
MainLauncher = true,
Theme = "@android:style/Theme.Holo.Light"
)]
public class MainActivity : Activity { ... }
You can also do this at the Application level. 您也可以在应用程序级别执行此操作。
But for your specific problem, it seems that you are naming your style files FsmTheme.xml
. 但是对于您的特定问题,您似乎正在命名样式文件FsmTheme.xml
。 That is incorrect. 那是不对的。 You must name any styling resources styles.xml
, so if you rename your files to Resources/values/styles.xml
and Resources/values-v11/styles.xml
everything should work as expected. 您必须为任何样式资源styles.xml
命名,因此如果将文件重命名为Resources/values/styles.xml
和Resources/values-v11/styles.xml
一切都应按预期工作。
The breakdown is on this line. 细分就在这条线上。
<application android:label="FutureState App Demo" android:icon="@drawable/Icon" Theme="@style/FsmTheme" />
Some of the tutorials out there show 一些教程显示
Theme="@style/ThemeName"
but you should actually structure it the same as the rest of the element 但实际上你应该和元素的其余部分一样构造它
android:theme="@style/ThemeName"
So the final structure will read 所以最终的结构将会阅读
<application android:label="FutureState App Demo" android:icon="@drawable/Icon" android:theme="@style/FsmTheme" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.