使用选项卡时FrameLayout上的顶部边框

时间:2011-01-16 09:28:26

标签: android tabs border tabwidget android-framelayout

我有一个在我的Android应用程序中使用选项卡的屏幕。 tabwidget和framelayout之间有一条线(如边框)​​。我想摆脱那条线,但似乎无法找到它是什么。我已经确定它是FrameLayout的一部分,它将其可见性设置为消失。请参考以下代码:

<?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:background="#fb8c10"
    >

    <ImageView
    android:id="@+id/img_confirm_header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/confirm_header"                 
    />

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_marginBottom="0dip"
        android:background="#fb8c10"                              
        android:tabStripEnabled="false"                         
        />

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"            
        android:background="@drawable/tab_bg"                                                
         />
</LinearLayout>
</TabHost>

这是当前布局的链接以及我正在尝试做的事情 http://img441.imageshack.us/g/screenshot20110116at513.png/

橙色布局是我的应用程序,灰色是我正在尝试做的。

注意灰色屏幕截图中的标签是如何流入框架的。

为链接道歉,我无法发布图片:p

谢谢!

2 个答案:

答案 0 :(得分:1)

刚才我遇到过这个问题。但是,我也试图删除FrameLayout的顶部边框。我做的。但我不认为这是一种删除顶部边界的方法。无论如何,仅供参考,

只需在Border上放置带背景白色的TextView并使用AbsoluteLayout。

例如:

<AbsoluteLayout>

<TabHost 
    android:layout_x="0dip"
    android:layout_y="5dip" ...>

    <AbsoluteLayout android:padding="5dip" android:background="#ffffff">
        <TabWidget/>
        <FrameLayout ....
        android:layout_x="0dip" android:layout_y="65dip" />
    </AbsoluteLayout>

</TabHost>

  <TextView 
    android:layout_width="fill_parent" android:layout_height="25dip" 
    android:layout_x="0dip" android:layout_y="65dip" 
    android:background="#ffffff"/>

</AbsoluteLayout>

答案 1 :(得分:1)

我设法通过使用相对布局操纵z-index来解决这个问题。我能够将标签稍微放在框架布局上。请参阅以下代码:

<?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:background="#fb8c10"
        >
        <ImageView
        android:id="@+id/img_confirm_header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/tab_header"

        />
        <RelativeLayout
        android:id="@+id/widget77"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@android:color/transparent"
        >                    
            <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"            
            android:background="@android:color/transparent"                             
            android:layout_marginTop="33dip"                                                   
             />
             <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"            
            android:background="#fb8c10"                              
            android:tabStripEnabled="true"  
            android:layout_above="@android:id/tabcontent"
            android:layout_marginBottom="40dip"                                            
            />
        </RelativeLayout>
    </LinearLayout>
</TabHost>