【发布时间】:2015-02-08 07:06:49
【问题描述】:
这是我的标签,它有一些额外的空格,我需要删除它们。 这是我的代码
<?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="match_parent"
android:padding="0dip"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
mainactivity 类:
public class MainActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
// Tab for Photos
TabSpec photospec = tabHost.newTabSpec("Photos");
// setting Title and Icon for the Tab
photospec.setIndicator("Photos");
// photospec.setText("da");
Intent photosIntent = new Intent(this, SplashActivity.class);
photospec.setContent(photosIntent);
// Tab for Videos
TabSpec videospec = tabHost.newTabSpec("Videos");
videospec.setIndicator("Videos");
Intent videosIntent = new Intent(this, MainActivity.class);
videospec.setContent(videosIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(photospec); // Adding photos tab
tabHost.addTab(videospec); // Adding videos tab
}
}
我尝试像这样更改布局中选项卡的大小
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="23dp"
android:padding="0dip" />
如果我这样做,此文本将被隐藏。
当我降低高度时,它会变成这样,并且文本也会隐藏
【问题讨论】:
-
为什么要使用已弃用的 TabActivity 。请使用 FragmentActivity 代替 TabActivity
标签: android android-layout android-tabs android-tablelayout android-tabactivity