注:要在包含button的父布局中设置

    android:layout_width="match_parent"       //外层大布局,设置为全部宽度,不然不会到屏幕最右端
    android:layout_height="wrap_content"
    android:orientation="horizontal" >
        android:layout_width="wrap_content"         //这是左侧显示的两个,要设置为适合,不然将会占据整个屏幕不能显示靠右的两个button了   默认靠左显示无需设置
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginLeft="10dp" >
     android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="插入"      
   android:id="@+id/bt_insert_notepad"
     />
    android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="查询"   
   android:id="@+id/bt_read_notepad"
     />
 
    android:layout_width="match_parent"      //这是靠右显示的,因为是犒右侧,所以要设置为全屏,全屏的意思就是除去上面两个按钮的空间下剩余空间全部
   android:layout_height="wrap_content"
   android:orientation="horizontal"
   android:gravity="right"                                //gravity是指里面的内容靠右显示,内容指的是里面的两个button
   android:layout_marginRight="10dp">
      android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="删除"      
   android:id="@+id/bt_delete_notepad"
     />
      android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="替换"  
   android:id="@+id/bt_update_notepad"
     />
   

关于gravity和layout_gravity的区别详情请看博客:http://blog.csdn.net/zhangjikuan/article/details/25736727

更多相关文章

  1. ktolin在Android中布局界面拼接
  2. android之布局LinearLayout
  3. android之线性布局LinearLayout以及weight权重使用
  4. 【Android】使用代码动态创建布局
  5. Android Studio 自带的侧滑布局设置
  6. Android应用.国际化-屏幕适配-样式与主题
  7. Android各种屏幕尺寸

随机推荐

  1. 深入探索 Android(安卓)电量优化
  2. Android,java,xml,xml读取与保存,基于And
  3. Android关于Dex拆分(MultiDex)技术详解
  4. [Android]Google Maps的申請、設定與使用
  5. 【Android】requestDisallowInterceptTou
  6. Android(安卓)平台侧性能优化之应用启动[
  7. 【android极光推送】—从客户端到后台,一
  8. Android(安卓)Studio Lint 自动检查清除
  9. Android(安卓)Dev Guide 中文版一 (原创,请
  10. 蜂窝教育:Android与iOS平分天下