嗨,今天我来分享一下Android中的布局,布局我今天为大家分享其中一个简单的布局:流式布局          1.所谓的流式布局,就是像流水一样直接自动从左到右,自动排序

然后通过控制其属性控制控件的位置,从而达到控制其位置,大家可以试着做一下下面这个题,对于刚入门Android的童鞋来说好玩到爆(@ ̄ー ̄@)
对,不用其他布局,只用流式布局来写这个,需要动一下你的脑筋,不要小看哦,也希望有童鞋有跟我的解决方案不同的话,可以在下面回复,让本人瞄俩眼也是可以的,O(∩_∩)O哈哈~



∨下面加上我的写法





首先,将orientation属性设置为horizontal,就是将他的大Linear设置为水平

然后在定义三个小的Linear

并且将三个的Width全设置为Wrap Content ,,Height全设置为、Matc Parent
然后在每个小Linear里面先创建一个Button


然后设置其每个Linear的Weight为0.3

 <LinearLayout        android:layout_width="wrap_content"        android:layout_height="match_parent"        android:layout_weight="0.3">        <Button            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="我是左上"/>    LinearLayout>    <LinearLayout        android:layout_width="wrap_content"        android:layout_height="match_parent"        android:layout_weight="0.3">        <Button            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="我是中间"/>    LinearLayout>    <LinearLayout        android:layout_width="wrap_content"        android:layout_height="match_parent"        android:layout_weight="0.3">        <Button            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="我是右上"/>    LinearLayout>

附加效果图

然后在设置其在所在的地方
左上的设置

 <LinearLayout        android:layout_width="wrap_content"        android:layout_height="match_parent"        android:layout_weight="0.3">                    android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="我是左上"            android:layout_gravity="left"/> ![这里写图片描述](https://img-blog.csdn.net/20170605225423955?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvUFpwZW5nemhlbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)   LinearLayout>

这样看上去没效果

再然后设置中间的

<LinearLayout        android:layout_width="wrap_content"        android:layout_height="match_parent"        android:layout_weight="0.3"        android:gravity="center">        <Button            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="我是中间"/>    LinearLayout>

附加效果图

效果显著
移到最中间了<( ̄ˇ ̄)/

然后处理右边的,移到右上角

<LinearLayout        android:layout_width="wrap_content"        android:layout_height="match_parent"        android:layout_weight="0.3"        android:gravity="right">        <Button            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="我是右上"/>    LinearLayout>

然后再附加效果图
再然后处理下面两个
在右边那个小Linear属性orientation设置为垂直(Vertical),gravity=”right”
在右边那个小Linear里面嵌套一个小小Linear,并且写个Button

<LinearLayout        android:layout_width="wrap_content"        android:layout_height="match_parent"        android:layout_weight="0.3"        android:gravity="right"        android:orientation="vertical">        <Button            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="我是右上"/>        <LinearLayout            android:layout_width="wrap_content"            android:layout_height="match_parent"            android:layout_weight="0.3"            android:gravity="right">            <Button                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="我是右下"/>        LinearLayout>    LinearLayout>

效果图。。。。ヾ(´∀`o)+

再设置小小Linear的button 中的layout_gravity设置为bottom

    <LinearLayout        android:layout_width="wrap_content"        android:layout_height="match_parent"        android:layout_weight="0.3"        android:gravity="right"        android:orientation="vertical">        <Button            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="我是右上"/>        <LinearLayout            android:layout_width="wrap_content"            android:layout_height="match_parent"            android:layout_weight="0.3"            android:gravity="right">            <Button                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="我是右下"                android:layout_gravity="bottom"/>        LinearLayout>    LinearLayout>

=.=效果图

完美哈哈哈,然后左边的跟上面进行差不多的处理,然后写完=.=
附加最后处理完的图 今天就分享这么多,哇咔咔

更多相关文章

  1. 一起Talk Android吧(第二百五十九回:Android中的Toolbar菜单二)
  2. Android(安卓)zar高速扫码程序,(比zxing快很多倍),包更小,扫码界面Xml
  3. android 页面布局时定义控件ID时@id/XX和@+id/xx 有什么区别?
  4. 花椒Android客户端多变体构建实践
  5. 鸿洋大神博文Android(安卓)自定义View (一)中自定义属性所遇到的
  6. Android实现左滑退出Activity(完美封装)
  7. Android(安卓)Q暗色模式适配踩坑—状态栏
  8. g1安装android软件详细攻略
  9. android重用layout-include标签的使用

随机推荐

  1. Android(安卓)SDCard Mount 流程分析(一)
  2. Android启动过程以及各个镜像的关系——
  3. Android(安卓)sp 指针类的用法
  4. 如何消除原生Android网络状态上的惊叹号
  5. Android设计规范
  6. 在英特尔®凌动™ 平台上进行 Android*
  7. Android事件分发机制完全解析,带你从源码
  8. 经典软件测试面试题目:Android(安卓)和 io
  9. Android的垃圾回收机制(android refbase类
  10. Android中Canvas绘图基础详解(附源码下载)