三月十日

今天要完成登陆界面的优化问题。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="@color/white"
/>
<corners
android:radius="10dp"
/>
</shape>
1.制作外框需要设置shape
2.stroke是描边属性,可以定义描边的宽度、颜色、虚实线等等。

 

3.corners标签是用来字义圆角的,其中radius与其他四个并不能共同使用。

<corners //定义圆角
android:radius="dimension" //全部的圆角半径
android:topLeftRadius="dimension" //左上角的圆角半径
android:topRightRadius="dimension" //右上角的圆角半径
android:bottomLeftRadius="dimension" //左下角的圆角半径
android:bottomRightRadius="dimension" /> //右下角的圆角半径

其效果图为

 

****************制作注册按钮

<LinearLayout

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
>
<Button
android:id="@+id/btn_login"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="登录"
android:textSize="20dp"
android:layout_marginLeft="20dp"
android:layout_gravity="center" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="注册"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
/>


</LinearLayout>

1.登录和注册按钮需要放到一个Linearlaout中

2.Android stdio中android:orientation设置为“vertical”和“horizontal”的区别

当在线性布局中LinearLayout设置了android:orientation="horizontal"时,表示此时的排列方式为水平方向

当在线性布局中LinearLayout设置了android:orientation="vertical"时,表示此时的排列方式为垂直方向

3.android:layout_weight为设置权重,在此前并不知手机屏幕宽度为多少,所以要将android:layout_weight=""设置为1。代码中登录和注册按钮的权重比例是1:1

 

posted @ 2023-03-11 10:36  布吉岛???  阅读(16)  评论(0编辑  收藏  举报