簡體   English   中英

如何使TabView中的標簽透明

[英]How do I make tabs in a tabview transparent

我如何制作一個標簽視圖,使標簽有點透明,以便您可以看到由標簽視圖托管的Listview的內容?

到目前為止,我嘗試通過設置Alpha來使選項卡/按鈕透明,但是我認為Tabhost的制作方式在按鈕后面沒有任何內容,因此使其透明只會顯示黑色背景

謝謝!

您可以隱藏選項卡小部件。 並使用按鈕

<?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">
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:id="@+id/header">
        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:text="woopra" android:textColor="#ffffff" android:textSize="36sp"
            android:textStyle="bold"/>
    </LinearLayout>       
    <FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
        <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" 
            android:layout_height="wrap_content" android:visibility="gone"/>            
        <LinearLayout android:layout_width="fill_parent" android:layout_height="64dip">
            <Button android:layout_height="fill_parent" android:layout_width="0dip" 
                android:layout_weight="1.0" android:id="@+id/dashboard_tab" 
                android:onClick="tabHandler" android:text="Dashboard"/>
            <Button android:layout_height="fill_parent" android:layout_width="0dip" 
                android:layout_weight="1.0" android:id="@+id/visitors_tab" 
                android:onClick="tabHandler" android:text="Vistors"/>
            <Button android:layout_height="fill_parent" android:layout_width="0dip" 
                android:layout_weight="1.0" android:id="@+id/chat_tab" android:onClick="tabHandler"
                android:text="Chat"/>
            <Button android:layout_height="fill_parent" android:layout_width="0dip" 
                android:layout_weight="1.0" android:id="@+id/reports_tab" 
                android:onClick="tabHandler" android:text="Reports"/>
        </LinearLayout> 
    </FrameLayout>
    <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="0dip"
                 android:layout_weight="1.0"/>
</LinearLayout>

我在這里使用了4個按鈕而不是tabwidget。 在按鈕的onclick中,我使用諸如tabHost.setCurrentTab(1);之類的東西。

將Alpha設置為按鈕應該起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM