实际上我已经在我的应用程序中创建了一个标签..现在的事情是,当我将我的标签的bacground颜色设置为白色它的工作但唯一的事情是灰色颜色下划线仍然出现所以任何人都可以告诉我如何删除该线..
我发送的代码和快照显示下划线的位置..
xml代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="horizontal"
android:background="#FFFFFF">
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp"/>
</LinearLayout>
</TabHost>
</LinearLayout>
java代码:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost MainTabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, ContactListForm.class);
spec = MainTabHost.newTabSpec("Contacts").setIndicator("Contacts",
res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent);
MainTabHost.addTab(spec);
intent = new Intent().setClass(this, CallDialerForm.class);
spec = MainTabHost.newTabSpec("Call").setIndicator("Call",
res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent);
MainTabHost.addTab(spec);
intent = new Intent().setClass(this, MyInfoForm.class);
spec = MainTabHost.newTabSpec("My Info").setIndicator("MyInfo",
res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent);
MainTabHost.addTab(spec);
MainTabHost.setCurrentTab(0);
for (int j = 0; j < MainTabHost.getTabWidget().getChildCount(); j++)
{
MainTabHost.getTabWidget().getChildAt(j).setBackgroundColor(Color.parseColor("#FFFFFF"));
}
}
快照:
答案 0 :(得分:1)
在设置标签的代码中使用此选项。请注意,仅从SDK 8开始支持它。
if(7 < Build.VERSION.SDK_INT){
tabHost.getTabWidget().setStripEnabled(false);
}
答案 1 :(得分:0)
我也是同一类型的问题,但我已经使用了代码
的最后一击删除了它 tabHost = getTabHost(); // The activity TabHost
tabHost.setOnTabChangedListener(this);
Resources res = getResources(); // Resource object to get Drawables
tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Reusable TabSpec for each tab
TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
TabSpec secondTabSpec = tabHost.newTabSpec("tid2");
TabSpec thirdTabSpec = tabHost.newTabSpec("tid3");
TabSpec fourthTabSpec = tabHost.newTabSpec("tid4");
TabSpec fifthTabSpec = tabHost.newTabSpec("tid5");
viewCache[0] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[1] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[2] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[3] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
viewCache[4] = LayoutInflater.from(this).inflate(R.layout.tabs1, null);
firstTabSpec.setIndicator(viewCache[0]);
secondTabSpec.setIndicator(viewCache[1]);
thirdTabSpec.setIndicator(viewCache[2]);
fourthTabSpec.setIndicator(viewCache[3]);
fifthTabSpec.setIndicator(viewCache[4]);
firstTabSpec.setContent(new Intent(this, HomeTabActivityGroup.class));
secondTabSpec
.setContent(new Intent(this, ProfileTabActivityGroup.class));
thirdTabSpec.setContent(new Intent(this,
NotificationTabActivityGroup.class));
fourthTabSpec.setContent(new Intent(this,
FavoritesTabActivityGroup.class));
fifthTabSpec
.setContent(new Intent(this, MoreTabActivityGroupNew.class));
tabHost.addTab(firstTabSpec);
tabHost.addTab(secondTabSpec);
tabHost.addTab(thirdTabSpec);
tabHost.addTab(fourthTabSpec);
tabHost.addTab(fifthTabSpec);
currentTabvalue = tabHost.getCurrentTab();
C2DMessaging.register(TennisAppActivity.mContext,
"racquetester@gmail.com");
for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
// tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#7392B5"));
switch (i) {
case 0:
tabHost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.home);
break;
case 1:
tabHost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.profile);
break;
case 2:
tabHost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.notifications);
break;
case 3:
tabHost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.fav);
break;
case 4:
tabHost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.more);
break;
}
}
// <强> * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** 强> 它是用于它的xml文件。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center">
<ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="50dip"></ImageView>
我希望对你有所帮助。