Android下一行平均分布图片的布局
来源:互联网 发布:朱迪福斯特 知乎 编辑:程序博客网 时间:2024/05/18 04:01
Android下一行平均分布图片的布局
这是一个很常见的需求,比如有三个图片按钮,需要在底部三个平均,比如下个例子:
以下是布局文件
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="10dp" > <ImageButton android:id="@+id/button_start" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/button_start" android:background="@android:color/transparent" /> <ImageButton android:id="@+id/imageView2" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:layout_weight="1" android:src="@drawable/button_heat" /> <ImageButton android:id="@+id/imageView2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/button_close" android:background="@android:color/transparent" /> </LinearLayout>
相应解释:
- 必须采用ImageButton 并且将图片设为前景(即android:src),用button背景或ImaageView的src 均不行,后者会造成图片拉伸填满整行。
- android:background="@android:color/transparent" 是防止ImageButton 出现缺省的按钮背景从而破坏效果。
- android:layout_width="match_parent" 和 android:layout_weight="1" 是配合达成平均分布效果,前者保存每个button拉伸成一样长,后面表示拉伸后各个控件比例是1:1:1
0 0
- Android下一行平均分布图片的布局
- Android 使用 TableLayout 布局拉伸宽度 平均分布各列
- 多个图片平均分布
- 自动布局按钮排列平均分布
- Android 水平平均布局
- Android 水平平均布局
- 平均分布的一些问题
- 平均分布TabLayout的tab
- 布局网页表格要求其列平均分布的简单操作
- 使用flex布局.平均排列.当屏幕宽度小于的时候,使其一行排列
- android:TableRow之平均分布列
- 整理Android的列表的一行布局
- Android中android:layout_weight属性解决不同机型平均分布的适配问题
- 如何平均得到圆内点的随机分布
- 如何平均得到圆内点的随机分布
- 关于Android连连看中的图片分布
- Android布局的高按照比例来分布
- Android下的布局
- ACM---1087: A+B for Input-Output Practice (III)
- 高负荷房价会根据各航空母舰赶快感觉烘干机烘干
- ACM---1088: A+B for Input-Output Practice (IV)
- 查看Android程序启动时间
- ACM---1089: A+B for Input-Output Practice (V)
- Android下一行平均分布图片的布局
- Ubuntu 14.04 LTS: File Sharing With Samba
- iOS 代码审查(Code Review for iOS)
- iOS 代码审查:宽松的指导方针(iOS Code Review: Loose Guidelines)
- windows 视频采集开源库
- wrhgrthrsthrth
- mingw 的 dll 导出为 windows 的lib
- 由动态库文件dll生成lib库文件
- 1.cocos2dx 3.2环境搭建