Android中Button

1.android:drawableTop="@drawable/accept"设置在按钮文本的上面绘制指定图片。可同时指定drawableLeft等其它方向

2.android:drawablePadding="30dp"设置在按钮文本与图片间距

3.ImageButton无法实现文字与图片同时显示的效果,Button则可以,设置 android:text="按钮5"  android:background="@drawable/add"

4.android:layout_toLeftOf="@id/comments_list_reply_zhan"实现在哪个控件的左侧

5.style="@style/main_tab_bottom" 当一个样式属性太多时,放到专门的文件styles.xml中引用

 <style name="main_tab_bottom">
        <item name="android:textSize">12.0dip</item>
        <item name="android:ellipsize">marquee</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:background">@drawable/home_btn_bg</item>
        <item name="android:paddingTop">5.0dip</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:button">@null</item>
        <item name="android:singleLine">true</item>
        <item name="android:drawablePadding">2.0dip</item>
        <item name="android:layout_weight">1.0</item>
    </style>

 <item name="android:background">@drawable/home_btn_bg</item>是设置按钮的动作效果

drawable文件夹中的home_btn_bg.xml文件中

<selector xmlns:android="http://schemas.android.com/apk/res/android">

 <item android:drawable="@drawable/newsdetails_titlebar_btn_previous" android:state_pressed="false"/>    

<item android:drawable="@drawable/newsdetails_titlebar_btn_previous_selected" android:state_pressed="true"/>    

<item android:drawable="@drawable/newsdetails_titlebar_btn_previous_selected" android:state_focused="true"/>    

<item android:drawable="@drawable/newsdetails_titlebar_btn_previous"/>

</selector>

newsdetails_titlebar_btn_previous为原图片,newsdetails_titlebar_btn_previous_selected为按下的图片

 layout_gravity:本控件在它父控件中的相对位置

gravity:本控件中的内容在本控件中的相对位置

posted @ 2013-01-21 15:26  欢醉  阅读(472)  评论(0编辑  收藏  举报