12

我建设,应该在Android 2.3的运行一个应用程序,我说都ActionBarSherlock和HoloEverywhere库。如何在使用ActionBarSherlock时应用HoloEverywhere android主题?

为了使用ActionBarSherlock我必须使用Theme.Sherlock像这样:

<application 
    ... 
    android:theme="@style/Theme.Sherlock" 
    ... > 

这是很正常的。

我的主要活动是非常简单:只是一个5行(我不使用ListAcivity)的ListView。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <ListView 
     android:id="@+id/menuListView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 

由于它的Android 2.3,我仍然有橙色&黑色主题(除了当然的动作条)。现在我想通过修改我的表现像这样添加HoloEverywhere主题:

<application 
    ... 
    android:theme="@style/Theme.HoloEverywhereDark.Sherlock" 
    ... > 

但是,这并不能改变什么......我在想什么?

+2

我需要像在以前的版本中ICS微调。但我试图导入ActionBarSherlock和Holoeverywhere。但在导入后在eclipse中抛出很多错误。还请告诉我们不能只使用holoeverywhere没有ActionBarSherlock? – Vins 2012-09-12 10:29:03

+0

哪个错误?是的,你可以使用Holoeverywhere without actionbarsherlock – Alexis 2012-09-12 14:07:37

+0

像资源未找到错误。我做的导入是 - >文件 - >新建项目 - > Android项目从现有的代码。 – Vins 2012-09-13 04:11:06

回答

7

要启用默认为每个的ListView我在HoloEverywhere库的styles.xml文件去了河洛主题,然后我加入这行修改了“ListViewStyle”元素:

<item name="android:listSelector">@drawable/list_selector_holo_dark</item> 
+1

是的。好点子。 – 2012-07-27 13:21:00

3

我与ListView的选择了同样的问题。我尽管这HoloEveruwhere将默认采用全息选择器(蓝色)(我曾经尝试都Theme.HoloEverywhereLight和Theme.HoloEverywhereLight),但事实并非如此。也许我错过了一些东西。

我结束了手动设置选择:

listView.setSelector(R.drawable.list_selector_holo_light); 

你有你可以利用(list_selector_holo_light为例)的库的若干绘图资源。

+0

这实际上工作,但我必须为每个ListView做到这一点。 – Alexis 2012-07-27 13:12:08

2

的便携式和正确的解决方案将从ListViewStyle继承并覆盖属性,在您的styles.xml中进行设置。

如果您在服务器上远程部署了HoloEverywhere官方库(例如Maven repo),则无法依赖它保留styles.xml中的更改(您正在根据自己的需要修改它)。

相关问题