Android开发学习之路03

在Android开发中,界面展示和逻辑处理通常通过布局文件和活动(Activity)来实现。

1. 界面展示

界面展示主要通过XML布局文件来实现。在res/layout目录下创建一个XML文件,比如activity_main.xml。以下是一个简单的示例:

xml
<!-- res/layout/activity_main.xml --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="16dp"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, Android!" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Click Me" /> </LinearLayout>

这个布局文件定义了一个垂直线性布局,包含一个文本视图(TextView)和一个按钮(Button)。

posted @   新晋软工小白  阅读(3)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示