0

ここに画像の説明を入力してくださいここに画像の説明を入力してくださいヘッダーには次のレイアウトがあります。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
 android:orientation="horizontal"
>


 <Button android:id="@+id/home"
  android:layout_width="0dp" 
  android:layout_height="wrap_content"
  android:layout_weight="1"
  android:text="Home"
  android:background="@drawable/ic_menu"
  android:textSize="11dp"
/>

<Button android:id="@+id/questions"
 android:layout_width="0dp" 
 android:layout_height="wrap_content"
 android:layout_weight="1"
 android:text="Questions"
 android:textSize="11dp"
   android:background="@drawable/ic_menu"
android:layout_toRightOf="@+id/home"  />  


 <Button android:id="@+id/businesses"
  android:layout_width="0dp" 
  android:layout_height="wrap_content"
  android:layout_weight="1"
  android:textSize="11dp"
  android:text="Businesses"
    android:background="@drawable/ic_menu"
  android:layout_toRightOf="@+id/questions"
 />  

 <Button android:id="@+id/learn"
  android:layout_width="0dp" 
  android:layout_height="wrap_content"
  android:layout_weight="1"
  android:text="Learn"
  android:textSize="11dp"
  android:background="@drawable/ic_menu"
  android:layout_toRightOf="@+id/businesses"
 />  

</LinearLayout>

ボタンの背景を画像で作ると、ボタンの間にスペースができなくなると思いました。現在、ヘッダーボタンは適切にレンダリングされますが、それらの間に厚い空白の背景スペースがあります。どうすればその空白を取り除き、それらの間のスペースを1pxにすることができますか?

エミュレータの写真をアップロードしました。画面上部の4つの暗いボックスが表示されますか?これがスペース付きのヘッダーです。

ありがとう!

4

2 に答える 2

1

ここで同様の質問に潜在的な解決策があります。ボタンを含むLinearLayoutのパディングを完全に排除する方法はありますか?

その画像に9パッチを使用している場合、描画可能なic_menuにパディングを含めることができます。作成するときは、9-のコンテンツ領域を指定するために、右と下に沿った黒い線が意図したとおりであることを確認してください。パッチを適用し、パディングに寄与する可能性があります。

また、ボタンのマージンとパディングの両方に0dpを追加してみてください。

お役に立てば幸いです。

于 2012-05-20T16:48:21.727 に答える
1

問題は、画像に境界線の色が含まれていることです。画像から境界線を削除するか、画像の中心色である単色#868686を使用します。

于 2012-05-20T17:11:58.650 に答える