LinearLayout中margin属性小结ZZ 分类: Android开发 2014-05-30 10:56 114人阅读 评论(0) 收藏
mainActivity如下:
-
package
com.c; -
-
import
android.os.Bundle; -
import
android.app.Activity; -
-
public
class MainActivity extendsActivity { -
-
@Override -
protected void onCreate(Bundle savedInstanceState) { -
super.onCreate(savedInstanceState); -
} -
public void testHorizontal(){ -
//
-
//
xmlns:android="http://schemas.android.com/apk/res/android" -
//
android:layout_width="match_parent" -
//
android:layout_height="match_parent" -
//
android:orientation="horizontal" -
//
> -
//
-
//
-
//
android:layout_width="wrap_content" -
//
android:layout_height="wrap_content" -
//
android:layout_marginLeft="20dip" -
//
android:layout_marginRight="10dip" -
//
android:text="button1" /> -
//
-
//
android:layout_width="wrap_content" -
//
android:layout_height="wrap_content" -
//
android:layout_marginLeft="20dip" -
//
android:layout_marginRight="20dip" -
//
android:text="button2" /> -
//
-
//
android:layout_width="wrap_content" -
//
android:layout_height="wrap_content" -
//
android:layout_marginLeft="20dip" -
//
android:layout_marginRight="10dip" -
//
android:text="button3" /> -
//
-
//
-
-
-
} -
-
}
**
horizontal.xml如下:
-
<</span>LinearLayout
-
xmlns:android="http://schemas.android.com/apk/res/android" -
android:layout_width="match_parent" -
android:layout_height="match_parent" -
android:orientation="horizontal" -
> -
<</span>Button -
android:layout_width="wrap_content" -
android:layout_height="wrap_content" -
android:layout_marginLeft="20dip" -
android:layout_marginRight="10dip" -
android:text="button1" /> -
<</span>Button -
android:layout_width="wrap_content" -
android:layout_height="wrap_content" -
android:layout_marginLeft="10dip" -
android:layout_marginRight="20dip" -
android:text="button2" /> -
<</span>Button -
android:layout_width="wrap_content" -
android:layout_height="wrap_content" -
android:layout_marginLeft="10dip" -
android:layout_marginRight="10dip" -
android:text="button3" /> -
-
</</span>LinearLayout>
vertical.xml如下:
-
<</span>LinearLayout
-
xmlns:android="http://schemas.android.com/apk/res/android" -
android:layout_width="match_parent" -
android:layout_height="match_parent" -
android:orientation="vertical" -
> -
-
<</span>Button -
android:layout_width="wrap_content" -
android:layout_height="wrap_content" -
android:layout_marginTop="30dip" -
android:layout_marginBottom="130dip" -
android:text="button1" /> -
<</span>Button -
android:layout_width="wrap_content" -
android:layout_height="wrap_content" -
android:layout_marginTop="60dip" -
android:text="button2" /> -
<</span>Button -
android:layout_width="wrap_content" -
android:layout_height="wrap_content" -
android:layout_marginTop="40dip" -
android:layout_marginBottom="10dip" -
android:text="button3" /> -
-
-
</</span>LinearLayout>
版权声明:本文为博主原创文章,未经博主允许不得转载。