Android 如何从FragmentTabhost中删除选定的选项卡指示器?
我尝试了几个链接来删除Android 如何从FragmentTabhost中删除选定的选项卡指示器?,android,android-tabhost,fragment-tab-host,Android,Android Tabhost,Fragment Tab Host,我尝试了几个链接来删除FragmentTabHost中的所选选项卡,但对我无效。 我在Xml中也尝试过这种方法,但它不起作用 android:tabStripEnabled="false" 这是我对fragmenttabhost的布局。 HTC设备 很抱歉回复晚了 我也遇到了这个问题,我尝试了很多方法,最后我成功了 试试下面的代码 fragmentTabHost.getTabWidget().getChildAt(“您的选项卡位置”).setBackground(null) 只需获取
FragmentTabHost
中的所选选项卡,但对我无效。我在Xml中也尝试过这种方法,但它不起作用
android:tabStripEnabled="false"
这是我对fragmenttabhost的布局。
HTC设备
很抱歉回复晚了
我也遇到了这个问题,我尝试了很多方法,最后我成功了
试试下面的代码
fragmentTabHost.getTabWidget().getChildAt(“您的选项卡位置”).setBackground(null)
只需获取child并将其背景设置为null,您就完成了。感谢您的回复。+1感谢您的努力…现在我对它没有任何要求…将在将来进行测试(所以我现在没有接受它…),当我做这类任务的时候..谢谢你的+1,这是我的责任发布答案,永远欢迎这个解决方案也会删除onclick动画。
<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>
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