排列方向

这段代码可以实现竖直排列。

    
可以vertical

下面的代码运行没有问题,但是为什么没有竖直排列?

    
没有vertical

将前一段代码的三行

    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:orientation="vertical" >~~~替换第二段代码的那三行,OK。![可以vertical了](http://upload-images.jianshu.io/upload_images/2994271-86d99e8c050e6972.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/240)差别是:android:orientation="vertical" >对的;android:layout_orientation = "vertical"错的当然排列方向可以横排horizental或者竖排vertical####高度宽度视图的高度、宽度都可以是固定的、wrap_content和match_parent试验如下代码:

android:layout_width = "wrap_content"android:layout_height = "wrap_content"android:orientation="vertical" >

android:text="Hi there!"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:textSize="36sp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/black"
android:background="#ccddff"
android:padding="20dp"/>

android:text="Hi there!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="36sp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/black"
android:background="#ccddff"
android:padding="20dp"/>

android:text="Hi there!"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="36sp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/black"
android:background="#ccddff"
android:padding="20dp"/>
android:id="@+id/button1"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#1cddff"
android:textSize="36sp"
android:text="Button 1" />

android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1cddff"
android:textSize="36sp"
android:text="Button 2" />

android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="36sp"
android:background="#1cddff"
android:text="Button 3"/>

![好乱](http://upload-images.jianshu.io/upload_images/2994271-080ea32a08896330.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/480)如果想要均衡地将这些视图分布在device上,简单暴力地这样固定长度高度或者match_parent、wrap_content是行不通的。我们去搜索一下LinearLayout有没有办法实现均衡布局?let's Google search for a potential solution to the problem.![可以得到一大堆结果](http://upload-images.jianshu.io/upload_images/2994271-17d74fb8b9750c54.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/480)[这个网站](http://stackoverflow.com)在你需要其他人帮助时,可以查找问题答案,别人可能已经遇到了同样的问题,并且提出了答案。或者贴出问题,让别人来帮助你。网站手机打不开那也没办法!![Paste_Image.png](http://upload-images.jianshu.io/upload_images/2994271-a4582ff494d22634.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/480)提示我们可以使用layout_weight属性。

更多相关文章

  1. android Timer的用法实例
  2. Android(安卓)代码执行Linux Shell小记
  3. android 横向滚动屏幕实现(1)
  4. Android中Crash(闪退,崩溃)的一般问题与解决方案
  5. android弹出框2(相当于通知)
  6. Android(安卓)1.5 1.6 2.0 2.1 2.2 2.3 3.0,4.0的区别
  7. Android(安卓)NDK学习 简介
  8. Android中拍照、图片、录音、视频和音频功能的方法和代码
  9. android:屏幕自适应

随机推荐

  1. 初学Android,图形图像之打砖块游戏(二十
  2. android 清除应用的缓存
  3. android用户网络检测工具
  4. Android防误按返回退出程序
  5. 分享:android之hardwareAccelerated你不知
  6. Android(安卓)设置Activity 全屏的方法
  7. Android读写文件工具类详解
  8. Android(安卓)Dilaog 设置没有标题注意的
  9. Android实现图片顺时逆时旋转及拖拽显示
  10. Android的drawable文件夹的说明