AndroidManifest文件设置
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test">
<!-- 使用联网权限-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:anyDensity="true"
android:icon="@mipmap/baby_icon"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:screenOrientation="landscape" # 设置横屏模式
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme">
<!-- 注册活动 -->
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden"
android:windowSoftInputMode="adjustUnspecified|stateHidden">
<!--设置启动页面过滤器-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity" />
<activity android:name=".ThirdActivity" />
</application>
</manifest>
布局:
相对布局:
内部
app:layout_constraintTop_toTopOf="parent" //与父组件顶对齐 第二个的头与第一个的头对齐
app:layout_constraintLeft_toLeftOf="parent" //与父组件左对齐
app:layout_constraintBottom_toBottomOf="parent" //与父组件底对齐
app:layout_constraintRight_toRightOf="parent" //与父组件右对齐
android:layout_marginTop="100dp" //顶部内偏移
android:layout_marginLeft="120dp" //左部内偏移
外部
android:layout_toRightOf="@+id/bt_1" //在bt_1右侧
android:layout_below="@id/bt_1" //在bt_1下方
android:layout_marginTop="15dp" //顶部外偏移
控件
TextView:
android:textSize="20sp" //设置字号
android:gravity="center" //文字居中对齐
android:textColor="@android:color/holo_blue_dark" //设置字体颜色
EditText
android:inputType="text" //控制输入类型
android:hint="请输入密码:" //设置输入提示
Button
ImageView