2011-02-25 22 views
0

次のコードを使用してカスタムタイトルバーを追加しましたが、底部に左右に約2ピクセルの間隔がありますが、カスタムタイトルバーをtitlbar領域に合わせることができますか?あなたは幅のためFILL_PARENTを使用したいと思います何かアドバイスカスタムタイトルバーはタイトルバー領域を埋めない

ジョナサン

customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
     setContentView(R.layout.tab); 
     Display display = getWindowManager().getDefaultDisplay(); 

     if (customTitleSupported) { 
      getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, 
          R.layout.titlebar); 

      LinearLayout titlebar = (LinearLayout) findViewById(R.id.TitleBarLayOut); 
      titlebar.setPadding(-2, -1, -2, -1); 
      titlebar.setMinimumWidth(display.getWidth()); 
      GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM, 
         new int[] {Color.RED, Color.YELLOW} 
        ); 
      titlebar.setBackgroundDrawable(grad); 

      playButton = new Button(this); 
      playButton.setText("Play"); 
      playButton.setGravity(Gravity.LEFT); 

      infoButton = new Button(this); 
      infoButton.setText("Info"); 
      infoButton.setGravity(Gravity.RIGHT); 

      titlebar.addView(playButton, new LinearLayout.LayoutParams(
         70,1)); 

      titlebar.addView(infoButton, new LinearLayout.LayoutParams(
        70,1)); 


     } 


<?xml version="1.0" encoding="utf-8"?> 

答えて

2

カスタム領域ではなく、実際のタイトルバーの背景を埋めることができます。 私のために働いた解決策を試してください:Set title background color

0

ため

感謝。 XML内:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
+0

申し訳ありません申し訳ありません私のレイアウトxml hadntを実現しました。私は塗りつぶし親として設定された幅を持っている –

+0

私はそれを知らない。 MinWidthとパディングを削除してみてください。 –

関連する問題