【问题标题】:Custom tab style (xml) not working in Android tabs (Appcelerator)自定义选项卡样式 (xml) 在 Android 选项卡中不起作用 (Appcelerator)
【发布时间】:2012-08-04 18:57:51
【问题描述】:

我想更改 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,引用drawable文件夹中的tab_selector.xml

我知道部分 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>

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

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-06
      • 1970-01-01
      • 2020-03-04
      • 1970-01-01
      • 1970-01-01
      • 2015-09-30
      相关资源
      最近更新 更多