在android中的控件LinearLayout 中的android:gravity="center" 属性,要么是居左、居右、居中对齐,不能达到双控件 两端对齐,

要实现两端对齐方式,要采用 中间增加一个控件的方式实现 ,并设置属性weight=1。

具体的布局文件如下:

<?xml version="1.0″ encoding="utf-8″?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="horizontal" >    <Button        android:id="@+id/Button01"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="button01" >    </Button>    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_weight="1" />    <Button        android:id="@+id/Button02"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="button02" >    </Button></LinearLayout>

效果如图:


实现两个button按钮 两端对齐

更多相关文章

  1. android中使用自定义控件checkbox,ToggleButton,ProgressBar
  2. Android(安卓)- NullPointerException
  3. Android(安卓)EditText 密码输入框可见性设置。
  4. 自定义ViewGroup控件 textView 的ellipsize end 属性无效
  5. Android(安卓)学习路线
  6. 关于android.os.NetworkOnMainThreadException
  7. Android实现一个通用的PopupWindow
  8. Android(安卓)PullToRefresh下拉刷新控件的简单使用
  9. Android(安卓)获取OnItemClick事件中组件的内容

随机推荐

  1. Android(安卓)okhttp: "java.net.Unknown
  2. Android之Fragment学习(四)
  3. Android(安卓)Studio运行项目提示Edit co
  4. MediaStore.ACTION_IMAGE_CAPTURE注意事
  5. android 给动画添加结束监听事件
  6. Android上试用Linphone(Free SIP VOIP Cl
  7. Android利用ViewFlipper实现屏幕切换动画
  8. Android(安卓)四种异步操作UI界面的方法
  9. Android(安卓)Root方法原理解析及Hook(四
  10. ListView与Button的共存问题解决