gpt4 book ai didi

android - 如何从 FragmentTabhost 中删除选定的选项卡指示器?

转载 作者:行者123 更新时间:2023-11-29 17:14:09 26 4
gpt4 key购买 nike

我已经尝试了几个链接来删除 FragmentTabHost 中的选定选项卡,但对我不起作用。
First link
Second link

我也在我的 Xml 中尝试过,但它不起作用

android:tabStripEnabled="false"

这是我对 fragmenttabhost 的布局。

<FrameLayout

android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"
/>
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:background="@drawable/top_bg"
app:tabIndicatorColor="#000"
android:tabStripEnabled="false"
app:tabIndicatorHeight="0dp"
android:layout_height="60dp"
>

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />

<LinearLayout
android:id="@+id/tab_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:showDividers="none"
android:orientation="horizontal"
android:weightSum="5" >

<ImageView
android:id="@+id/genralTabBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:padding="15dp"
android:background="@drawable/button_1_off" />

<ImageView
android:id="@+id/treandingTabBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:padding="12dp"
android:background="@drawable/button_2_off" />

<ImageView
android:id="@+id/profileTabBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:padding="12dp"
android:background="@drawable/button_3_off" />

</android.support.v4.app.FragmentTabHost>

在我的设备中选择的标签看起来像(请检查图像)

Moto E 设备

Moto E device

HTC 设备 HTC device

最佳答案

抱歉回复晚了我也遇到了这个问题,我尝试了很多东西,最后我成功了。

Try This Below code.

 fragmentTabHost.addTab(fragmentTabHost.newTabSpec("tab1").setIndicator("", getResources().getDrawable(R.drawable.tab1)),
HomeFragment.class, null);

fragmentTabHost.getTabWidget().getChildAt(0).setBackground(null);//set child background as null
fragmentTabHost.addTab(fragmentTabHost.newTabSpec("tab2").setIndicator("", getResources().getDrawable(R.drawable.tab2)),
CartFragment.class, null);
fragmentTabHost.getTabWidget().getChildAt(1).setBackground(null););//set child background as null

fragmentTabHost.addTab(fragmentTabHost.newTabSpec("tab3").setIndicator("", getResources().getDrawable(R.drawable.tab3)),
MoreStuffFragment.class, null);
fragmentTabHost.getTabWidget().getChildAt(2).setBackground(null); );//set child background as null

fragmentTabHost.getTabWidget().getChildAt("Your tab position").setBackground(null);

简单地说,你必须得到 child 并将它的背景设置为 null,你就完成了

关于android - 如何从 FragmentTabhost 中删除选定的选项卡指示器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39717362/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com