【问题标题】:android holo theme backgroundandroid全息主题背景
【发布时间】:2012-05-08 09:26:19
【问题描述】:

我想知道,是否可以将使用android的holo主题时显示的背景作为drawable? (你知道,3.0+ 显示的深黑色和蓝色背景)我需要将它用作可绘制对象,所以如果有人知道这是否可以做到,请告诉我..

抱歉,我忘了说这是在平板设备上显示的,不知道是在手机上。

【问题讨论】:

  • 你能给个例子截图吗?我不知道你说的是哪个背景。在 Holo Theme 中没有这样的东西(据我所知)......这也是一个非编程问题。
  • 我添加了一个截图。我的问题是,我可以将此背景的资源作为可绘制对象吗?也许这是不可能的..但值得一试。

标签: android background themes


【解决方案1】:

文件位置

全息黑暗:

/path_to_sdk/platforms/android-version/data/res/drawable/background_holo_dark.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
            android:startColor="#ff000000"
            android:endColor="#ff272d33"
            android:angle="270" />
</shape>

全息光:

/path_to_sdk/platforms/android-version/data/res/drawable/background_holo_light.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
            android:startColor="#ffe8e8e8"
            android:endColor="#ffffffff"
            android:angle="270" />
</shape>

自己制作

将以下代码放入res/drawable/background.xml

<?xml version="1.0" encoding="utf-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
    >
<gradient 
    android:angle="270"
    android:startColor="#ff020202"
    android:endColor="#ff272D33"
    android:type="linear" />
</shape>

将背景引用添加到您的父视图组

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background">

反复调整这些值,直到获得所需的效果。

【讨论】:

  • 我需要一个drawable,因为我正在使用renderscript,但感谢你的建议,我一定会试试这个,也许用于其他目的。
  • 我对渲染脚本一无所知,但如果你膨胀那个形状,你会得到一个从 Drawable 扩展而来的 ShapeDrawable
【解决方案2】:

如果可能,最好的办法是查看 3.0 的 android .jar(可以在 Eclipse 中使用 ADT 下载) 图像可能在 /drawable/drawable-hdpi 或 /drawable 中的某个地方找到

如果没有,很可能只能在源码中找到。

【讨论】:

  • 我会尝试 .jar,因为 android honeycomb 的源代码不可用,也永远不会可用。谢谢你的建议
  • 啊,是的,我忘记了 3.0 的琐事;)
【解决方案3】:

在这里,也许这会有所帮助:http://developer.android.com/guide/topics/ui/themes.html

【讨论】:

  • 感谢您的回复,但我需要背景作为可绘制对象,以便在 .java 类中使用它。我知道您可以为活动应用主题,但我遇到的问题是我在应用程序中使用渲染脚本,因此主题的背景从未显示在 RSSurfaceView 上。
猜你喜欢
  • 1970-01-01
  • 2012-07-31
  • 2016-10-13
  • 1970-01-01
  • 1970-01-01
  • 2014-09-06
  • 2015-06-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多