English 中文(简体)
甲型六氯环己烷 我如何在主题上界定习俗的颜色、可提取物等?
原标题:android: How can I define custom colors, drawables, etc. in themes?
  • 时间:2012-05-11 03:29:00
  •  标签:
  • android

我希望我能解释一下我之后的情况。 从本质上讲,我的用户要求我允许我对我的申请持不同看法,我希望我能够处理主题。

我希望我能够这样做:

<style name="NewTheme" parent="android:Theme.Dark">
  <item name="labelColor">#f90</item>
  <item name="buttonColor">#fff</item>
  <item name="buttonBg">@drawable/button</item>
</style>
<style name="OldTheme" parent="android:Theme.Dark">
  <item name="labelColor">#fa0</item>
  <item name="buttonColor">#88f</item>
  <item name="buttonBg">@drawable/button_old</item>
</style>

然后在我的风格中参考这些价值观:

<style name="labelStyle">
  <item name="android:textColor>@labelColor</item>
</style>
<style name="buttonStyle">
  <item name="android:textcolor">@buttonColor</item>
  <item name="android:background">@buttonBg</item>
</style>

I know this syntax is wrong, but what might be the right syntax? Basically, I want to create sets of attributes (color, background, a couple other things) and select them based on theme.

最佳回答

3. 与安乐斯的主题和风格合作:

  1. Define one or more themes in themes.xml and set the definitions of your styles there.

  2. Define custom attributes, a.k.a. custom styles, in attrs.xml.

  3. 描述您的习俗风格是什么。

  4. In your layout files, give your views a style attribute, which has a custom style name as their values.

  5. Set the theme of your application or activity in either AndroidManifest.xml or in the Activity s onCreate(). This is done by calling setTheme() in the activity s onCreate() method, before any call to setContentView().

  6. 为了改变这个主题,你完全需要重新开始你的活动。

enter image description here

http://www.androidengineer.com/201006/using-themes-in-android-applications.html”rel=“nofollow noreferer” 它涉及一名方案管理员希望就海底专题开展工作的所有事项(文字色、文字格式、国家清单可提取等)。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签