こんな感じのレイアウトにしてみました
ちょっとボタンタイプのように見えます.テキストと画像の両方をボタンに実装するにはどうすればよいですか?
カスタムボタンを次のように作成します。
ステップ1: res / drawable / button_background.xmlにボタンの描画可能な形状xmlを作成します:
<?xml version=”1.0″ encoding=”UTF-8″?>
<shape xmlns:android=”http://schemas.android.com/apk/res/android”>
<solid android:color=”#F000″/>
<stroke android:width=”1px” android:color=”#BB000000″ />
<padding
android:left=”10dp”
android:top=”7dp”
android:right=”10dp”
android:bottom=”7dp”
/>
<corners
android:bottomRightRadius=”5dp”
android:bottomLeftRadius=”5dp”
android:topLeftRadius=”5dp”
android:topRightRadius=”5dp”
/>
<gradient
android:angle=”90″
android:startColor=”#777″
android:centerColor=”#777″
android:endColor=”#BBB”
android:type=”linear”
/>
</shape>
ステップ2:メインのButtonxmlレイアウトを次のように追加します。
<Button android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Facebook"
android:drawableLeft="@drawable/leftimg"
android:drawableRight="@drawable/rightimg"
android:padding="15dip"
android:background="@drawable/button_background"/>
ボタンでこれを行うことができますandroid:drawableLeft="@drawable/your_icon"