实际上我想在我的标签的右下方显示曲线。那怎么办呢......我用过的代码..
Xml代码
<?xml version="1.0" encoding="utf-8"?>
<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">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<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"/>
</LinearLayout>
</TabHost>
第二个xml的代码
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/ic_tab_artists_white"
android:state_selected="true"
android:state_pressed="false" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/ic_tab_artists_grey" />
</selector>
<。pv文件的代码
Resources res = getResources();
final TabHost MainTabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
MainTabHost.getTabWidget().setStripEnabled(false);
//call calendar Activity class
intent = new Intent().setClass(this, CalendarForm.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = MainTabHost.newTabSpec(res.getString(R.string.text_tabHost1)).setIndicator("Calendar",
res.getDrawable(R.drawable.calendar_ic)).setContent(intent);
MainTabHost.addTab(spec);
//call History Activity class
intent = new Intent().setClass(this, HistoryForm.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = MainTabHost.newTabSpec(res.getString(R.string.text_tabHost2)).setIndicator("History",
res.getDrawable(R.drawable.calendar_ic)).setContent(intent);
MainTabHost.addTab(spec);
//call Statistic Activity class
intent = new Intent().setClass(this, StatisticForm.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = MainTabHost.newTabSpec(res.getString(R.string.text_tabHost3)).setIndicator("Statistic",
res.getDrawable(R.drawable.calendar_ic)).setContent(intent);
MainTabHost.addTab(spec);
//setbackground Style of tabHost
MainTabHost.setCurrentTab(0);
MainTabHost.getTabWidget().setWeightSum(3);
final TabWidget tabHost=getTabWidget();
MainTabHost.setBackgroundResource(R.drawable.back_image);
for (int j = 0; j < MainTabHost.getTabWidget().getChildCount(); j++)
{
((TextView)tabHost.getChildAt(j).findViewById(android.R.id.title)).setTextColor(Color.parseColor("#FFFFFF"));
((TextView)tabHost.getChildAt(j).findViewById(android.R.id.title)).setTextSize(16);
}
这就是我所得到的...其中标签是正方形现在我希望我的标签曲线位于右下方
答案 0 :(得分:2)
检查下面的问题,你可以得到一个想法。
how-to-put-some-finishing-touches-rounded-edges
还有另一种解决方案是在标签上设置带圆角的图像,我知道,这是一种俗气的解决方案,但有效。
tab = tabs.newTabSpec("tab_Busquedas");
tab.setContent(new Intent().setClassName("com.grapp", "com.grapp.homes").putExtras(bundle));
tab.setIndicator(null,null);
tabs.addTab(tab);
//here you set the image with rounded corners over the tab.
tabs.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.mytab_roundedcorners);
R.drawable.mytab_roundedcorners
将成为选择器。
修改强>
放置代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>
在drawable文件夹中的xml文件中。然后使用xml文件作为选项卡的背景。它将是一个圆角。