Android 水平平均布局
2015-06-07 10:01
337 查看
需要在界面中,对指定的控件水平平均布局时,可采用如下方式:
其中,最重要的属性是 layout_weight="1"时,剩余空间平均分配,=0时,按实际大小分配。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="45dp" android:orientation="horizontal" android:gravity="bottom" > <ImageButton android:id="@+id/id_title_left_btn" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/ic_launcher" android:layout_weight="1" /> <ImageButton android:id="@+id/id_title_left_btn1" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/ic_launcher" android:layout_weight="1" /> <ImageButton android:id="@+id/id_title_left_btn2" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/ic_launcher" android:layout_weight="1" /> <ImageButton android:id="@+id/id_title_left_btn3" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/ic_launcher" android:layout_weight="1" /> </LinearLayout>
其中,最重要的属性是 layout_weight="1"时,剩余空间平均分配,=0时,按实际大小分配。
android:layout_weight
相关文章推荐
- Android Studio使用注意事项
- Android25闹钟项目——ArrayAdapter动态添加数据,显示数据,删除数据SharedPreferences存储数据,读取数据
- 常用的android弹出对话框
- FFmpeg编译之后的Android平台移植---------阿冬
- Android属性动画完全解析(上),初识属性动画的基本用法
- Android异步任务AsyncTask
- Android25闹钟项目——刷新时间
- android:windowSoftInputMode属性详解
- Android25闹钟项目——tabhost的使用
- Android 实现用户列表信息的功能,然后选择删除幻灯片删除功能
- Android-onInterceptTouchEvent()和onTouchEvent()总结
- Android studio -SVN 使用笔记
- Android自定义Dialog
- Android的Window类
- Android ViewPager 如何判断当前页面是从前一页还是后一页滑动过来
- android EditText+ListView的组合(类似于AutoCompleteTextView)
- Android 程序框架设计
- Android 模块化编译的一些问题解决方案
- android 用Fragment实现如新浪微博一样的底部菜单的切换
- Android 详解AsyncTask的使用