让用户选择一个主题[机器人]

编程入门 行业动态 更新时间:2024-10-27 02:27:24
本文介绍了让用户选择一个主题[机器人]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个应用程序我工作中,我试图让用户改变主题或布局的外观。像一些应用程序怎么也得在那里你可以选择轻主题或黑暗的主题选项。

I'm have an app i'm working on in which I'm trying to let the user change the "theme" or the look of the layouts. Like how some apps have the option where you can pick the "Light theme" or the "Dark Theme".

因此​​,基本上,我需要用以下帮助:

So basically I need help with the following:

  • 是否有任何内置的主题,在Android中,我可以使用?
  • 如何获得访问的主题?
  • 在任何其他有用的信息。我真的在这个新的。
推荐答案

您需要使用标准的 Android的主题/风格的过程,并建立你想提供给用户(例如,在主题/资源列表光=> R.style.MyLightTheme,黑暗=> R .style.MyDarkTheme,iPhone=> R.style.iOSTheme)。揭露可用的主题是清单给用户,例如目录preference 在preferences /设置屏幕。

You would need to create your themes using the standard Android theme/style process, and build a list of the Themes/resources you want to make available to the user (e.g., "Light" => R.style.MyLightTheme, "Dark" => R.style.MyDarkTheme, "iPhone" => R.style.iOSTheme). Expose that list of available themes to the user as, for example, a ListPreference in a Preferences/Settings screen.

在你活动的的onCreate()办法(S),之前调用的setContentView(),通过设置主题this.setTheme(customTheme);

In your Activity's onCreate() method(s), before calling setContentView(), set the theme using this.setTheme(customTheme);

customTheme 将来自的共享preferences 的上述

更多推荐

让用户选择一个主题[机器人]

本文发布于:2023-11-06 21:51:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564777.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:机器人   主题   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!