Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.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_Android Support Library_Android Design Library_Androiddesignsupport - Fatal编程技术网

Android 支持设计小部件TabLayout中的自定义选项卡指示器形状

Android 支持设计小部件TabLayout中的自定义选项卡指示器形状,android,android-support-library,android-design-library,androiddesignsupport,Android,Android Support Library,Android Design Library,Androiddesignsupport,实际上,默认情况下选项卡是矩形的,但我想制作自定义形状。我已经做了一些编码,但现在有一些标签之间的空间,我希望他们都在一起。请帮忙 但是: MainActivity.java final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.addTab(tabLayout.newTab().setText("First")); tabLayout.addTab(tabLayout.ne

实际上,默认情况下选项卡是矩形的,但我想制作自定义形状。我已经做了一些编码,但现在有一些标签之间的空间,我希望他们都在一起。请帮忙

但是:

MainActivity.java

    final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.addTab(tabLayout.newTab().setText("First"));
    tabLayout.addTab(tabLayout.newTab().setText("Second"));
    tabLayout.addTab(tabLayout.newTab().setText("Third"));
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
activity_main.xml

    <android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="27dp"
    android:minHeight="?attr/actionBarSize"
    app:tabBackground="@drawable/customtabhandler"
    />

customtabhandler.xml

<?xml version="1.0" encoding="utf-8"?>


defualttab.xml


onselectedtab.xml


任何帮助都将不胜感激


另外,我在stackoverflow上搜索了很多,只找到了旧的库,但没有找到新的库。

您的链接已断开
<!-- Non focused states -->
<item android:state_selected="false"
    android:drawable="@drawable/defualttab" />

<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item  android:state_selected="true"
    android:drawable="@drawable/onselectedtab" />
<!-- Colored rectangle-->
<item>
    <shape android:shape="rectangle">
        <size
            android:width="95dp"
            android:height="20dp" />
        <solid android:color="#ff30a3b6" />
    </shape>
</item>
<!-- Colored rectangle-->
<item>
    <shape android:shape="rectangle">
        <size
            android:width="95dp"
            android:height="20dp" />
        <solid android:color="#89aaaaaa" />
    </shape>
</item>

<!-- This rectangle for the left side -->
<!-- Its color should be the same as layout's background -->
<item
    android:right="100dp"
    android:left="-100dp"
    android:top="-100dp"
    android:bottom="-100dp">
    <rotate
        android:fromDegrees="45">
        <shape android:shape="rectangle">
            <solid android:color="#ff30a3b6" />
        </shape>
    </rotate>
</item>

<!-- This rectangle for the right side -->
<!-- Their color should be the same as layout's background -->
<item
    android:right="-100dp"
    android:left="100dp"
    android:top="-100dp"
    android:bottom="-100dp">
    <rotate
        android:fromDegrees="45">
        <shape android:shape="rectangle">
            <solid android:color="#ff30a3b6" />
        </shape>
    </rotate>
</item>