Android:常用空间的使用方法

match_parent:当前控件的大小和父布局的大小一样,由父布局来决定当前控件的大小。

wrap_content:当前控件的大小能够刚好包住里边的内容,由控件内容来决定当前控件的大小。

 <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Hello Android!"
        android:textColor="#2196F3"
        android:textSize="24sp"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="60dp" />

                                                  

一、TextView

gravity:文字的对齐方式

center等价于center_vertical|center_horizontal

vertical:垂直的  horizontal:水平的

textSize .textColor      字体大小的单位:sp

 <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Hello Android!"
        android:textColor="#2196F3"
        android:textSize="24sp"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="60dp" />

二、Button

系统会对Button中的所有英文字母进行大写转换

禁用此属性方法:android:textAllCaps="false"

监听器的两种实现方式:

①匿名类的方式实现监视器

②实现接口的方式来实现注册

三、EditText

hint :提示语句

maxLine:最大的输入行数

maxLength:最大的可允许输入个数

android:password="true"  //输入数据不显示  显示对应个数的·

android:phoneNumber="true"  //限定输入的必须是手机号

获取EditText中的内容:

EditText editText;

editText=(EditText)findViewById(R.id.名称);

注:获取文件中的内容需要放在监听里,否则会造成无法获取输入的内容

   <EditText
        android:id="@+id/edit_text"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="140dp"
        android:hint="Type something here"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:ignore="MissingConstraints" />

四、ImageView

在res目录下创建不同分辨率的drawable文件,将照片直接拖入drawable文件中即可。

也可以结合Button中的监听器进行动态的改变图片。

  <ImageView
        android:id="@+id/image_view"
        android:layout_width="249dp"
        android:layout_height="232dp"
        android:src="@drawable/chengdu"
        tools:ignore="MissingConstraints"
        tools:layout_editor_absoluteX="81dp"
        tools:layout_editor_absoluteY="176dp" />

小白:从入门到放弃,可能标签不全,用到再加,未完待续......

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值