手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

安卓如何实现线性布局

时间:2024-10-13 14:58:10

1、打开我们的编辑软件eclipse软件,如图所示;然后建立一个工程,至于怎么建工程,我相信小伙伴们应该知道怎么弄了;

安卓如何实现线性布局

2、找到文件目录,res-layout下的一个文件,然后选择,activity_main.xml。如图中所示,打开文档。

安卓如何实现线性布局

3、在整个界面中输入一下代码:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="寻迹" android:layout_weight="1" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 壁障" android:layout_weight="1" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 追踪" android:layout_weight="1" /> <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 学习" android:layout_weight="1" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /></LinearLayout>接着保存;

安卓如何实现线性布局

4、点击如图所示的地方进行执行,我们的软件;

安卓如何实现线性布局

5、如图所示,我们的执行结果如下;

安卓如何实现线性布局
© 手抄报圈