我正在开发一个需要底部选项卡的应用程序。我在他们的位置有标签,但标签和屏幕的底部,左侧和右侧之间有一个空的空间。 我下载了一个示例代码,看起来完全如何我想要我的标签,但空间不断出现。 http://postimg.org/image/6ft0v2qyn/底部的选项卡不能填满屏幕
我多么希望我的标签看: http://postimg.org/image/az9l93ymx/
对不起,我不能直接发表图片,因为我没有足够的声誉
我的应用程序。
XML布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TabHost
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"
android:padding="5dp">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="@drawable/tab_background" />
</LinearLayout>
</TabHost>
<!-- Listview to display slider menu -->
</android.support.v4.widget.DrawerLayout>
功能,用于将突片:
private void addTab(String labelId, int drawableId, Class<?> c)
{
TabHost tabHost = getTabHost();
Intent intent = new Intent(this, c);
TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
TextView title = (TextView) tabIndicator.findViewById(R.id.title);
title.setText(labelId);
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
icon.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
//tabHost.getTabWidget().setDividerDrawable(null);
//tabHost.setCurrentTab(2);
}
传递参数的函数:
addTab("Send News", R.drawable.icon_sendnews, SendNewsActivity.class);
解决:该tabHost有5DP填充,我不知道它是从哪里来的,但是当我移除它时,标签呈现出我想要的形状:D 任何帮助表示赞赏:)
你读过这个吗? http://developer.android.com/design/patterns/pure-android.html – 2Dee
如何插入标签? – Farhan
@ 2Dee:我已经阅读过,我甚至不喜欢底部的标签,但它是这个应用程序所必需的:/ – nick28