zoukankan      html  css  js  c++  java
  • 布局TextView和EditText区别,layout_width和lay_weight区别--Android Studio

    1. TextView控件是文本表示控件,主要功能是向用户展示文本的内容,它是不可编辑的,如设置标题;EditText控件是编辑文本控件,主要功能是让用户输入文本的内容,它是可以编辑的。
    每一个控件都有着与之相应的属性,通过选择不同的属性,给予其值,能够实现不同的效果。
    2. layout_width属性值设置为wrap_content时,获得的空间仅够描绘自身,还有额外的空间。layout_weight的属性值进行额外的空间分配。
    如果layout_width="0dp",则只考虑layout_weight属性值。
    <LinearLayout
        android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp">

    <Button
    android:text="Button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/crime_date"
    android:layout_weight="1"
    />
    <CheckBox
    android:id="@+id/crime_solved"
    android:text="@string/crime_solved_label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_weight="1"/>
    </LinearLayout>
    如代码:LinearLayout有两个控件,Button 和CheckBox.

    第一步查看layout_width属性值(竖直方向则查看layout_height)。因为设置为wrap_content时,获得的空间仅够描绘自身,还有额外的空间。
    第二步LinearLayout依据layout_weight的属性值进行额外的空间分配。两个子组件属性值同为1。因为均分了同样大小的额外空间。若设Button的layout_weight的值为2,则将获得2/3的额外空间,
    CheckBox组件获得剩余的1/3。







  • 相关阅读:
    获取单选框的值
    HTML5本地存储详解
    设为首页和加入收藏
    用PhotoSwipe制作相册,手势可放大
    iOS 加载本地 HTML 文件 CSS 样式图片无效果
    PhotoSwipe简介
    Flexslider图片轮播、文字图片相结合滑动切换效果
    网页中插入视频的方法----腾讯、优酷为例
    webapp在Android中点击链接的时候会有淡蓝色的遮罩层
    C# 获取北京时间 (根据纪元时间(1970/1/1)转换为DateTime)
  • 原文地址:https://www.cnblogs.com/phpli/p/5945311.html
Copyright © 2011-2022 走看看