私がする必要があるのは、背景が指定されておらず、デフォルトの灰色の背景画像が表示されている場合のように、背景画像がボタンの自然なサイズを埋めることです。しかし、代わりに、ボタンはテキストではなく背景画像のサイズに合わせて拡大されます。
以前の質問がありましたが、誰も解決策を持っていませんでした.
ボタン:
<Button
android:id="@+id/morebtn"
style="@style/CustomButton"
android:text="More" />
このカスタム ボタン スタイルがあります (灰色のボタンは 9 パッチです)。
<resources>
<style name="CustomButton" parent="@android:style/TextAppearance">
<item name="android:textColor">#FFFFFF</item>
<item name="android:layout_marginLeft">10dip</item>
<item name="android:layout_marginRight">10dip</item>
<item name="android:layout_marginBottom">10dip</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_centerInParent">true</item>
<item name="android:background">@drawable/greybutton</item>
<item name="android:textSize">20sp</item>
</style>
</resources>
現在、wrap_content に指示されているにもかかわらず、画面の幅がいっぱいになります。ボタン スタイルからandroid:backgroundを削除すると、ボタンが縮小してテキストが期待どおりに折り返されます。
私の背景画像がデフォルトのボタンの背景のように振る舞わない理由は誰にも分かりますか?