2011-12-04 31 views
0

我已經自定義了我的標題欄。 的問題是,雖然我所提到的寬度FILL_PARENT其不與一些空白空間上側任android自定義標題沒有填充父寬度

代碼是下面

<resources> 
    <style name="LargeTitleTheme"> 
     <item name="android:windowTitleSize">40dip</item> 
    </style> 
</resources> 

XML2填充父 :

<RelativeLayout android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
     <TextView android:id="@+id/textview" android:textStyle="bold" 
      android:layout_width="fill_parent" android:layout_height="wrap_content" 
      android:gravity="center" android:text="fggffgjjkki" 
      android:textSize="30sp" 
         android:textColor="#FFFFFF" android:background="@drawable/top_bar" /> 
</RelativeLayout> 

代碼:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
     setContentView(R.layout.homegrid); 
     getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.customtitle); 

回答

1

我曾遇到同樣的問題,在標題的左側和右側,有一些灰色填充。

然後我按照這裏討論的步驟Android: Custom Title Bar,並在與自定義標題背景顏色相同的自定義樣式中指定背景顏色。然後它工作!

  • Herojit
+0

它的工作就像奇蹟。謝謝你的答案 – png

0

嘗試添加android:l ayout_marginLeft =「0dp」android:layout_marginRight =「0dp」到RelativeLayout。

+0

遺憾的是它不工作 – png