Android Studio_day02 实际应用登录界面

序章:

今天做了个登录界面,新学了<ImageView>控件,<TextView>空间和输入框<EditText>,主要考验的还是布局的使用。还有边距。

图片控件<ImageView>:

顾名思义嘛,图片控件当然是插入图片的,图片嘛可以设置的高度和宽度都是自适应和充满,什么你问我什么是自适应和充满?自己去day_01看,图片没什么好说的,实际上他也是算是一个控件,只不过插入的是图片罢了。

文字控件<TextView>

顾名思义嘛,文字控件肯定是插入文字的,写完了之后文字就显示出来啦,但是请你千万记住,文字的敢赌和宽度只能设置为自适应,啥,为什么?找我老师说去,我哪知道,自适应就是宽度和高度都是“wrap_content”,当然了文字肯定是会有内容的,内容也是使用<android:text="内容">,那么,文字肯定是需要有大小的,android:textSize="20dp"这就是设置大小的方法,dp是单位,啥?为啥是dp,肯定不是dp阿是sp,边距和布局之类的才用dp的,问我为啥写dp,因为我老师给我讲的我忘了....  言归正传,请看下一标题。

输入框控件<EditText>:

这个实际上就是用户输入内容的文本框,这个文本框也是可以设置大小的,至于怎么设置去看day_01,设置方法都是一样的,同理他也是可以设置ID和大小的以及文本框的提示语的,是不是感觉很简单,直接Text提示就出来了,想多了,提示语是需要这个语句的android:hint="提示内容",什么什么?在哪里写这个,肯定是在<EditText>标签里啊,还能在哪,当然了也可以设置提示文字的大小,但是记得是单位是sp。

边距:

这就是一个属性,比如这个android:layout_marginLeft="边距多大dp",这个就是左边距,至于右边距,上边距下边距嘛,自己猜,嘿嘿!

                                                                                                                        持之以恒

下面来看看代码吧

<?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">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="50dp">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="20dp"
            android:background="@drawable/fahui" />

        <TextView
            android:layout_centerHorizontal="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="登录"
            android:textSize="20dp" />

    </RelativeLayout>

<RelativeLayout
    android:orientation="horizontal"
    android:layout_marginTop="120dp"
    android:layout_width="match_parent"
    android:layout_height="50dp">

    <TextView
        android:layout_centerVertical="true"
        android:textColor="#000000"
        android:text="账号"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="20dp"
        android:textSize="20dp" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="80dp"
        android:layout_marginRight="20dp"
        android:hint="请输入账号"
        android:textColor="#000000" />
</RelativeLayout>
    <RelativeLayout
        android:layout_marginTop="240dp"
        android:layout_width="match_parent"
        android:layout_height="50dp">

        <TextView
            android:layout_marginTop="120dp"
            android:layout_centerVertical="true"
            android:textColor="#000000"
            android:text="密码"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:textSize="20dp" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="60sp"
            android:layout_centerVertical="true"
            android:layout_marginLeft="80dp"
            android:layout_marginRight="20dp"
            android:hint="请输入密码"
            android:textColor="#000000" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="80dp"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="100dp"
            android:background="@drawable/zhifubao" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/weixin" />
    </LinearLayout>



</RelativeLayout>
效果图看封面吧

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值