2014-02-14 39 views
0

我正在開發一個需要底部選項卡的應用程序。我在他們的位置有標籤,但標籤和屏幕的底部,左側和右側之間有一個空的空間。 我下載了一個示例代碼,看起來完全如何我想要我的標籤,但空間不斷出現。 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 任何幫助表示讚賞:)

+1

你讀過這個嗎? http://developer.android.com/design/patterns/pure-android.html – 2Dee

+1

如何插入標籤? – Farhan

+0

@ 2Dee:我已經閱讀過,我甚至不喜歡底部的標籤,但它是這個應用程序所必需的:/ – nick28

回答

0

可能在您的片段您沒有刪除的佈局邊距

+0

哪個片段佈局?對於每個選項卡,我使用從各自類中調用的不同類型的佈局。 – nick28