jichat开工第一天

从DSP底层软件开发转Android软件开发,重拾毕业前的技能,作为求职路上的第一个练手项目。

初步需求:

客户端:1.登录注册,2.收发信息并显示出来,支持发送图片、视频,3.退出登录、注销账号

服务端:1.建立数据库保存用户账号密码,增删改查,2.接收并转发所有信息

初步需求就这样,后续可以慢慢增加。

开工第一天先实现登录注册界面,开工。

问题1:在相对布局中如何在让两个线性布局上下分布,原本以为在父容器中增加:

android:orientation="vertical"

就可以,结果效果如下:


至于原因没有去深究,不过用另一种方式:给第一个线性布局添加ID,让第二个线性布局位于该ID的下方就实现了我要的结果

<LinearLayout
    android:id="@+id/LL_un"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_centerInParent="true">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginLeft="10dp"
        android:textSize="18sp"
        android:textStyle="bold"
        android:text="user name" />
    <EditText
        android:id="@+id/un"
        android:layout_width="0dp"
        android:layout_weight="3"
        android:layout_height="wrap_content"
        android:layout_marginRight="30dp"
        android:hint="User name" />
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_centerInParent="true"
    android:layout_below="@id/LL_un">
    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginLeft="10dp"
        android:textSize="18sp"
        android:textStyle="bold"
        android:text="PassWord" />
    <EditText
        android:id="@+id/Pw"
        android:layout_width="0dp"
        android:layout_weight="3"
        android:layout_height="wrap_content"
        android:layout_marginRight="30dp"
        android:hint="Enter your password" />
</LinearLayout>

最终效果:



代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center_vertical"
    tools:context="com.example.administrator.myapplication.MainActivity">
    <LinearLayout
        android:id="@+id/LL_un"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_centerInParent="true">
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="10dp"
            android:textSize="18sp"
            android:textStyle="bold"
            android:text="user name" />
        <EditText
            android:id="@+id/et_un"
            android:layout_width="0dp"
            android:layout_weight="3"
            android:layout_height="wrap_content"
            android:layout_marginRight="30dp"
            android:selectAllOnFocus="true"
            android:hint="User name" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/LL_pw"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_centerInParent="true"
        android:layout_below="@id/LL_un">
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="10dp"
            android:textSize="18sp"
            android:textStyle="bold"
            android:text="PassWord" />
        <EditText
            android:id="@+id/et_Pw"
            android:layout_width="0dp"
            android:layout_weight="3"
            android:layout_height="wrap_content"
            android:layout_marginRight="30dp"
            android:selectAllOnFocus="true"
            android:hint="Enter your password" />
    </LinearLayout>


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_centerInParent="true"
        android:layout_marginTop="20dp"
        android:layout_below="@id/LL_pw">

        <Button
            android:id="@+id/bt_register"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="18sp"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="100dp"
            android:textStyle="bold"
            android:text="注册" />
        <Button
            android:id="@+id/bt_login"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="18sp"
            android:textStyle="bold"
            android:layout_marginRight="30dp"
            android:text="登录" />
    </LinearLayout>



</RelativeLayout>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值