首页 > 其他分享 >三月九日

三月九日

时间:2023-03-09 20:55:32浏览次数:405  
标签:控件 layout parent gravity 九日 三月 android id

今天要学习textview、button、edittext制作简易的登陆页面。什么是textview、button、edittext和讲解属性、设置、和对应java文件如何设置。

1.android:maxEms=""是设置每一行有多少个字符。

2.android:maxLines=""为设置行数。

3.android:ellipsiza=""为显示省略号,具体代码以及效果图如下

 

 4.android:layout_gravity="" 和android:gravity=""区别

android:gravity:这个是针对控件里的元素来说的,用来控制元素在该控件里的显示位置。例如,在一个Button按钮控件中设置如下两个属性,android:gravity="left"和android:text="提交",这时Button上的文字“提交”将会位于Button的左部。

android:layout_gravity:这个是针对控件本身而言,用来控制该控件在包含该控件的父控件中的位置。同样,当我们在Button按钮控件中设置android:layout_gravity="left"属性时,表示该Button按钮将位于界面的左部。

5.android:layout_marginTop=""为部件距离顶部的距离。 

6.android:layout_marginTop=""为用户名和密码类似两个部件之间的距离。android:padding=""为部件距离周边的距离。

 

 7.android:inputType="textPassword"为设置密码看不到例如*号显示。

今日所编代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="每日登陆打卡"
android:textSize="35dp"
android:gravity="center"
android:layout_marginTop="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/et_1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="25dp"
android:textColor="@color/black"
android:hint="用户名"
android:maxLines="1"
android:padding="10dp"

/>
<EditText
android:id="@+id/et_2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="25dp"
android:textColor="@color/black"
android:hint="密码"
android:maxLines="1"
android:padding="10dp"
android:layout_marginTop="10dp"
android:inputType="textPassword"
/>
<Button
android:id="@+id/btn_login"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="登录"
android:textSize="20dp"
android:layout_marginTop="20dp"
android:layout_gravity="center"
/>

</LinearLayout>
效果图:

 

标签:控件,layout,parent,gravity,九日,三月,android,id
From: https://www.cnblogs.com/mine-my/p/17201368.html

相关文章

  • 三月八日
    今天接着昨天的内容Android开发日志打卡APP(二)地址为(6条消息)Android开发日志打卡APP(二)_android中app开发日报_失散多年的哥哥的博客-CSDN博客。但是优点看不明白,还是转战......
  • 三月七日
    今天学习的内容主要是android开发打卡app(一)其博客地址为(6条消息)Android开发日志打卡APP(一)_失散多年的哥哥的博客-CSDN博客在app中主要用到的控件又:TextView、Button、E......
  • 三月六日
    今天上课王建民老师讲了关于代码的测试,代码要一个一个模块的进行测试,而不是堆积在一起,这样既烦乱又容易出现错误。其次讲了代码的三个重要知识点,格式,变量名和注释。课后小......
  • 2023年2月中国数据库排行榜:OTO新格局持续三月,人大金仓、AnalyticDB排名创新高
    玉兔迎春至,榜单焕新颜。 2023年2月,兔年开年的 墨天轮中国数据库流行度排行 火热出炉,本月共有259个数据库参与排名,排行榜样式去掉了较上月和半年前得分差的数据显示,更加......
  • 二月不减肥三月徒伤悲,手机怎么每天提醒自己减肥?
    进入2023年的公历2月后,我国很多地区的天气都在转暖,紧接着我们身上的衣服就要一件一件变薄了,再等一段时间就到了需要“露肉”的季节。爱美之心人皆有之,于是有不少女孩们都......
  • 三月来百草开 盈香满袖万物苏
    三月来百草开盈香满袖万物苏虫鸣和着欢笑心事舒三月来暖阳复相携去踏青处陌上花开满路香入土三月来有归人马踏浅草声催促春有期归有日今归途三月来生情愫春......
  • 2022DASCTF X SU 三月春季挑战赛 web
    1.ezpop2.calc3.upgdstoreezpop给出了源码:<?phpclasscrow{public$v1;public$v2;functioneval(){echonew$this->v1($this->v2);......