ナビゲーションバーのレイアウトに問題があります。私はボタンの中央にあるテキストの下にあるアイコンを持つことを望んでいました。現在、アイコンが描画されると、ページ外にテキストがプッシュされます。それを取り戻すための唯一の方法は、アンドロイドを使用することです:drawablePadding =「」(hereから)負の値を使用したが、それは次のようになります。Android:画像ボタンアイコンとテキスト
<LinearLayout android:id="@+id/navbar"
android:layout_alignParentBottom="true" android:gravity="center"
android:layout_width="fill_parent" android:background="#001"
android:layout_height="60dip" android:layout_weight="1"
android:orientation="horizontal">
<Button android:layout_height="fill_parent" android:id="@+id/navhomebtn" android:enabled="false"
android:textColor="#FFF" android:background="@drawable/navbuttonselected" android:drawableTop="@drawable/homeicon"
android:drawablePadding="-40dip"
android:text="Home" android:layout_weight=".25" android:layout_width="0dip" />
<Button android:layout_height="fill_parent" android:id="@+id/navsearchbtn"
android:textColor="#FFF" android:background="@drawable/navbuttons"
android:text="Search" android:layout_weight=".25"
android:layout_width="0dip" />
<Button android:layout_height="fill_parent" android:id="@+id/navfavbtn"
android:textColor="#FFF" android:background="@drawable/navbuttons"
android:text="Favorites" android:layout_weight=".25"
android:layout_width="0dip" />
<Button android:layout_height="fill_parent" android:id="@+id/navlistbtn"
android:textColor="#FFF" android:background="@drawable/navbuttons"
android:text="Loans" android:layout_weight=".25"
android:layout_width="0dip" />
</LinearLayout>
:
私のXMLは次のようになりますあなたはこのように行うことができ、ボタンのテキストや画像を設定するには
ちょうどすべての余分なパラメータ(layout_weight、パディング、背景を)失うそれまではすべてが正しく表示されます。次に、bacyを段階的に追加し始めます。問題が見つかるでしょう。テキストとバックグラウンドのボタンが画像を正しく中央揃えしていることをテストしただけで、問題は余分なパラメータのどこかに隠れているはずです。 –