自定义选项卡样式(xml)在Android选项卡中不起作用(Appcelerator)

时间:2012-08-04 18:57:51

标签: android titanium appcelerator titanium-mobile appcelerator-mobile

我想更改Android标签的默认背景颜色。我正在使用Appcelerator框架创建应用程序。但是更改选项卡样式仍然需要我创建xml文件。因此原生Android开发人员也可以帮助我。

无论如何,我创建了以下xml代码:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="0dp"
        android:background="@drawable/tab_selector" >

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="0dp"
            android:layout_weight="1" />

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0" />
    </LinearLayout>
</TabHost>

在那里,我尝试指定background,在tab_selector.xml文件夹中注明drawable

我知道xml的一部分可以工作,因为它也会将我的标签放在底部。

然后在tab_selector.xml我有:

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true">
        <shape> 
            <gradient 
                android:endColor="#ffffff" 
                android:startColor="#AAAAAA" 
                android:angle="270" /> 
            <stroke 
                android:width="1px" 
                android:color="#000000" /> 
        </shape>
    </item>

    <item
        android:state_selected="false" 
        android:state_focused="false" 
        android:state_pressed="false">
        <shape> 
            <gradient 
                android:endColor="#ffffff" 
                android:startColor="#AAAAAA" 
                android:angle="270" /> 
            <stroke 
                android:width="1px" 
                android:color="#000000" /> 
        </shape>
    </item>

    <!-- and the other states. They are the same as the ones above -->
    ...
    ...
    ...

</selector>

但是当我运行我的应用程序时,我仍然需要旧的原始标签样式。知道我的标签样式没有应用的原因吗?

1 个答案:

答案 0 :(得分:0)

嘿,你可能会尝试this 我觉得这对你很有用, 干杯......!