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。







  • 相关阅读:
    数据库根据两列数据得到层级关系SQL Queries to Manage Hierarchical or Parent-child Relational Rows in SQL Server
    escape from braxis site:us.forums.blizzard.com
    LEFT JOIN vs. LEFT OUTER JOIN in SQL Server
    Why do I have more rows after LEFT JOIN?
    Why is the IIS default app pool recycle set to 1740 minutes?
    IIS Best Practices
    USB挂载&U盘启动
    OPKG 介绍
    OPKG 配置
    OPKG 软件包管理
  • 原文地址:https://www.cnblogs.com/phpli/p/5945311.html
Copyright © 2011-2022 走看看