基于Android studio登陆界面的布局代码
时间: 2023-12-10 10:42:05 浏览: 77
下面是一个基于 Android Studio 的登录界面布局代码示例:
```xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<ImageView
android:src="@drawable/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="32dp"/>
<EditText
android:id="@+id/edit_text_username"
android:hint="Username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"/>
<EditText
android:id="@+id/edit_text_password"
android:hint="Password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"/>
<Button
android:text="Login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"/>
</LinearLayout>
```
该布局文件使用了一个线性布局(LinearLayout)作为根布局,其中嵌套了一个图片视图(ImageView)、两个文本编辑框(EditText)和一个按钮(Button)。其中,ImageView 用于显示应用程序图标,EditText 用于输入用户名和密码,Button 用于提交登录信息。在实际应用中,可以根据需要添加其他视图组件或调整布局样式。