本文是关于第一篇博文里的项目布局的修改
将main.xml里面的绝对布局改为线性布局即可,感觉这样看起来舒服些!
|
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10px" android:background="@color/gainsboro" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="18sp" android:text="@string/info" android:textColor="@color/blue" /> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" > <!-- 建立一個EditText --> <EditText android:id="@+id/myEditText1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="18sp" android:layout_weight="1" /> <!-- 建立一個Button --> <Button android:id="@+id/query" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/chaxun" android:layout_weight="2" /> <Button android:id="@+id/reset" android:layout_height="fill_parent" android:layout_width="fill_parent" android:text="@string/qingkong" android:layout_weight="2" /> </LinearLayout> <!-- 建立一個WebView --> <WebView android:id="@+id/myWebView1" android:layout_height="fill_parent" android:layout_width="fill_parent" android:focusable="false" /> </LinearLayout> |

本文介绍了一个项目的XML布局从绝对布局转换为线性布局的过程。通过使用垂直和水平的LinearLayout,提高了布局的灵活性与美观性。文章详细展示了修改后的XML代码,并介绍了各个组件如TextView、EditText、Button和WebView的具体配置。
1548

被折叠的 条评论
为什么被折叠?



