添加空格布局空格、布局

由网友(难遇)分享简介:我试图让内Android的空行。这是我一直在做的:I am trying to make empty lines within android. This is what I have been doing:android:layout_width="fill_parent" android:layout_he...

我试图让内Android的空行。这是我一直在做的:

I am trying to make empty lines within android. This is what I have been doing:

android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="nn"

我想知道是否有更好的办法?谢谢

I want to know if there is a better way? Thanks

推荐答案

使用空间或视图中添加一个空格具体金额。对于30垂直密度像素:

Use Space or View to add a specific amount of space. For 30 vertical density pixels:

<Space
  android:layout_width="1dp"
  android:layout_height="30dp"/>

如果你需要一个灵活的空间填料,在LinearLayout中使用的物品之间的观点:

If you need a flexible space-filler, use View between items in a LinearLayout:

<View
  android:layout_width="1dp"
  android:layout_height="match_parent"
  android:layout_weight="1"/>

<View
  android:layout_width="1dp"
  android:layout_height="0dp"
  android:layout_weight="1"/>

这适用于大多数布局API 14安培;后来,除了小部件(使用的FrameLayout代替)。

This works for most layouts for API 14 & later, except widgets (use FrameLayout instead).

[更新二千零一十四分之九使用空间。帽尖到@Sean]

[Updated 9/2014 to use Space. Hat tip to @Sean]

阅读全文

相关推荐

最新文章