如何从FragmentTabhost中删除选定的选项卡指示器?
问题描述:
我尝试了几个链接来删除FragmentTabHost
中的选定标签,但不适用于我。
First link
Second link
如何从FragmentTabhost中删除选定的选项卡指示器?
我已经在我的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>
在我的设备选择的标签看起来像(PLZ检查图像)
摩托è设备
答
对不起迟到回复 我也得到这个问题,我想就可以了很多东西,我终于得到成功。
请尝试以下代码。
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( “您的标签位置”)的setBackground(空)。
只要你必须让孩子和设置它的背景,空和你做了
..Thanks对URS就可以回复.. + 1你的努力。现在我还没有任何它的要求...将在未来测试(所以我现在不接受....),当我会做这种类型的任务..谢谢 –
感谢您的+1,这是我的责任来发布答案和随时欢迎 –
此解决方案还将删除onclick动画。 – skymedium