【问题标题】:top border on FrameLayout when using tabs使用选项卡时 FrameLayout 上的顶部边框
【发布时间】:2011-01-16 09:28:26
【问题描述】:

我有一个在我的 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

谢谢!

【问题讨论】:

    标签: android tabs border tabwidget android-framelayout


    【解决方案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>
    

    【讨论】:

      【解决方案2】:

      刚才我遇到了这个问题。但是,我也尝试删除 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>
      

      【讨论】:

      • 感谢您的回答,但我不喜欢使用绝对定位,因为我针对多种屏幕尺寸。我能够解决这个问题,但是,我将在上面发布代码
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-02-04
      • 2015-11-26
      • 2021-08-06
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多