Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在TabLayout下面添加一行_Android_Xml_Android Tablayout_Tabbar - Fatal编程技术网

Android 在TabLayout下面添加一行

Android 在TabLayout下面添加一行,android,xml,android-tablayout,tabbar,Android,Xml,Android Tablayout,Tabbar,尝试在表格布局下方添加一行时遇到问题,但它必须位于选择器行后面。应该是这样的: 我已经尝试添加一个自定义视图,但每个选项卡都有一些空白,所以没有成功 有什么想法吗 这就是我现在得到的: 下面是我在XML上添加它的方式: <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="

尝试在
表格布局
下方添加一行时遇到问题,但它必须位于选择器行后面。应该是这样的:

我已经尝试添加一个自定义视图,但每个选项卡都有一些空白,所以没有成功

有什么想法吗

这就是我现在得到的:

下面是我在XML上添加它的方式:

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    app:tabBackground="@color/white"
    app:tabIndicatorColor="@color/colorAccent"
    app:tabTextColor="@color/white"/>

在可绘制文件夹中创建一个xml

background.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:top="-10dp" android:right="-10dp" android:left="-10dp">
        <shape 
            android:shape="rectangle">
            <solid android:color="#1bd4f6" />
            <stroke
                android:width="2dp"
                android:color="#0288D1" />
        </shape>
    </item>

</layer-list>
根据需要更改值和颜色

输出:


你可以试试这个。解决方案

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.design.widget.TabLayout
       android:id="@+id/tabs"
       android:layout_width="match_parent"
       android:layout_height="60dp"
       app:tabBackground="@color/white"
       app:tabIndicatorColor="@color/colorAccent"
       app:tabIndicatorHeight="2.5dp"
       app:tabTextColor="@color/white"/>

    <View
       android:layout_width="match_parent"
       android:layout_height="2.5dp"
       android:layout_gravity="bottom"
       android:background="#c6c6c6" />

</FrameLayout>


您的xml在哪里?预期输出如果你能添加实际上很简单,我会将其添加到问题中,但每个选项卡内部都有一些空白。你想在选项卡内部或选项卡按钮下方添加该行吗?应该与上面的图像完全相同。我真的很挣扎,直到我没有得到那个xoxo。我看到下面的绿色选择器没有任何内容:[@Felipe Castilhos你检查过了吗?很明显,我试图在标签上设置背景而不是表格本身是错误的。@Felipe Castilhos我很高兴这有帮助:)如果你想要其他边缘,你可以删除负值!好的luckI做了,会在TabLayoutSelector上显示灰色线。但是谢谢你的回答。
  <android.support.design.widget.TabLayout
        android:background="@drawable/background"
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        app:tabIndicatorColor="@color/colorAccent"
        app:tabTextColor="@color/white"/>
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.design.widget.TabLayout
       android:id="@+id/tabs"
       android:layout_width="match_parent"
       android:layout_height="60dp"
       app:tabBackground="@color/white"
       app:tabIndicatorColor="@color/colorAccent"
       app:tabIndicatorHeight="2.5dp"
       app:tabTextColor="@color/white"/>

    <View
       android:layout_width="match_parent"
       android:layout_height="2.5dp"
       android:layout_gravity="bottom"
       android:background="#c6c6c6" />

</FrameLayout>