android studio 控件登录界面
时间: 2023-07-07 22:38:07 浏览: 56
下面是一个简单的Android Studio控件登录界面的代码示例:
```xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:src="@drawable/ic_launcher"/>
<EditText
android:id="@+id/usernameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="50dp"
android:hint="Username"
android:inputType="text"/>
<EditText
android:id="@+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/usernameEditText"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:hint="Password"
android:inputType="textPassword"/>
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/passwordEditText"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="50dp"
android:text="Login"/>
</RelativeLayout>
```
这个界面包含一个ImageView、两个EditText和一个Button。ImageView用于显示应用的图标,两个EditText用于输入用户名和密码,Button用于提交登录信息。
在Activity中,可以通过findViewById()方法获取这些控件,并添加事件监听器来响应用户的操作。