布局与控件XML

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值