安卓开发activity布局
时间: 2023-10-29 11:06:41 浏览: 34
在安卓开发中,可以使用XML文件来定义Activity的布局。可以使用各种布局容器(如LinearLayout、RelativeLayout、FrameLayout等)和视图控件(如TextView、Button、ImageView等)来构建布局。在XML文件中,可以设置视图控件的属性(如大小、颜色、位置等)以及布局容器的属性(如方向、对齐方式等)。
例如,以下是一个简单的XML布局文件,其中包含一个TextView和一个Button:
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me!" />
</LinearLayout>
```