ㅤcoderitl

V1

2022/09/11阅读:30主题:橙心

Android-基础布局使用

登录

  • 线性布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/primary_gray"
    android:elevation="3dp"
    android:orientation="vertical">


    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_gravity="center"
        android:layout_marginTop="50dp"
        android:orientation="vertical"
        android:src="@drawable/avatar" />


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:background="@color/white"
        android:orientation="horizontal">


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:text="账号:"
            android:textSize="22dp" />


        <EditText
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:hint="在此输入账号"
            android:textSize="22dp" />



    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:background="@color/white"
        android:orientation="horizontal">


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:text="密码: "
            android:textSize="22dp" />


        <EditText
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:hint="在此输入账号密码"
            android:inputType="textPassword"
            android:textSize="22dp" />


    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:background="@color/white"
        android:orientation="horizontal">



        <RadioGroup
            android:layout_width="370dp"
            android:layout_height="wrap_content"
            android:orientation="horizontal">


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:text="性别: "
                android:textSize="22dp" />


            <RadioButton
                android:id="@+id/male"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="30dp"
                android:gravity="center"
                android:text="男"
                android:textSize="22dp" />


            <RadioButton
                android:id="@+id/fmale"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="女"
                android:textSize="22dp" />

        </RadioGroup>
    </LinearLayout>

    <Button
        android:layout_width="180dp"
        android:layout_height="65dp"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:backgroundTint="#3C8DC4"
        android:text="登录"
        android:textSize="22dp" />

</LinearLayout>
  • 颜色配置
<!-- 顶部区域颜色 -->
  <color name="deep_dark_green">#00574B</color>
  <!-- 顶部区域下颜色 -->
  <color name="dark_green">#008577</color>
  <color name="primary_gray">#E6E6E6</color>
  <color name="red_line">#f00</color>
  • 主题配置
<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.AndroidApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <item name="colorAccent">@color/primary_gray</item>
        <!-- AppCompatEditText默认状态状态设置底线颜色 -->
        <item name="colorControlNormal">#F00</item>
        <!-- AppCompatEditText选择的底线颜色 -->
        <item name="colorControlActivated">#F00</item>
    
</style>
</resources>
  • 结果

分类:

后端

标签:

Java

作者介绍

ㅤcoderitl
V1