WEB开发网      濂界珯濂藉垎浜紒浣犵殑涓€浠藉垎浜槸鎴戜滑鐨勪竴浠藉姩鍔涳紱璇峰垎浜� ---锕�
开发学院手机开发Android 开发 android LinearLayout排版(基本) 阅读

android LinearLayout排版(基本)

 2010-07-21 01:02:00 来源:WEB开发网 銆�鍑忓皬瀛椾綋澧炲ぇ瀛椾綋銆�  鍏虫敞榫欐尟鍗囩殑寰崥
核心提示:在android配置文件中,可以设置LinearLayout进行横排和竖排,android LinearLayout排版(基本),LinearLayout 中有一个属性android:orientation=""vertical表示竖排;horizontal表示横排;android:layout_w

android配置文件中,可以设置LinearLayout进行横排和竖排,LinearLayout 中有一个属性

android:orientation=""

vertical表示竖排;horizontal表示横排;

android:layout_width=""

此句表明这个控件的宽,这里可以填写**px,也可以填fill_parent表示从此控件左端开始铺满整个横屏,wrap_content表示从此控件左端开始当此控件中内容有多大,这个控件就占多大的位置。

LinearLayout 可以相互嵌套,

例如:

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical" android:layout_width="fill_parent"

android:layout_height="fill_parent">

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="horizontal" android:layout_width="fill_parent"

android:layout_height="fill_parent">

< /LinearLayout >

< /LinearLayout >

这个例子表示一个竖型的LinearLayout 中含有一个横行的LinearLayout,

以下是我写的一个计算器demo的xml源代码:

< ?xml version="1.0" encoding="utf-8"?>

< ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical" android:layout_width="match_parent"

android:layout_height="match_parent">

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical" android:layout_width="fill_parent"

android:layout_height="fill_parent">

< EditText xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/myField" android:layout_width="200px"

android:layout_height="50px" android:singleLine="false"

android:editable="false" />

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="horizontal" android:layout_width="fill_parent"

1 2 3  下一页

Tags:android LinearLayout

编辑录入:coldstar [复制链接] [打 印]
赞助商链接