大叔的第四天@既有图片又有文字的Button按钮

网上想做这种有很多方法,有些定义一个Button的Style比较麻烦。

自己的尝试::

ImageButton不能添加文字

Button把图片当背景图片将被拉伸

LinearLayout中加入文字和图片将没有按钮效果

经过不断尝试得到了一个满意的方法,非常简单,就是用一个FrameLayout布局,放入一个文字一个图片,代码如下

<FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="50dp" 
        android:orientation="horizontal">
            <Button
                android:id="@+id/single_jieqimen"
                android:layout_width="fill_parent"
                  android:layout_height="fill_parent" 
                />
            <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:paddingLeft="10dp"
            android:paddingBottom="3dp"
            android:textColor="#555555"
            android:text="清洗节气门"/>
            <ImageView 
                android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                android:textColor="#555555"
                android:layout_gravity="center_vertical|right"
                android:paddingRight="10dp"
                android:src="@drawable/icon_arraw2"/>
        
        </FrameLayout>

 

posted @ 2013-03-08 13:36  linsen@java  阅读(431)  评论(0编辑  收藏  举报