admin 发表于 2024-2-26 17:12:52

layouts

view groups包括

LinearLaout
ViewGroup to use for a strictly horizontal list-style arrangement of views.
ViewGroup that is useful for a strictly vertical list-style arrangement of views.


ConstraintLayout
A ViewGroup where elements can be arranged freely, are placed by the system based on constraints, and may adapt in size based on screen size and orientation.




ScrollView


ViewGroup to use when you need to scroll a single view vertically.






admin 发表于 2024-2-26 19:30:20

android:layout_gravity="center_horizontal"

属性用于在父容器中水平居中对齐一个视图

admin 发表于 2024-2-27 12:26:45

      android:layout_alignParentBottom="true"
      android:layout_marginLeft="20dp"
      android:layout_marginBottom="6dp"

这个定位在底部牛逼

admin 发表于 2024-2-27 22:13:35

      <activity
            android:name=".MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.Aboutme4">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
      </activity>


如果建立activity运行APP报错unable to determine activity name就对照上面代码修改Manifest文件

admin 发表于 2024-3-17 23:02:53

Fixed constraint固定约束A constraint that is specified using a hard-coded number.
Adaptable constraint可适应约束A constraint that defines a relationship in relative and weighted terms.
Absolute positioning绝对定位Positioning is numerical, such as the position in x, y coordinates.
Relative positioning相对定位Views are positioned by specifyingrelationship to other views.



Fixed constraint(固定约束):这是指使用硬编码的数值来指定约束条件。例如,将视图的宽度或高度设置为具体的数值。

Adaptable constraint(可适应约束):这是指使用相对和权重的方式来定义约束条件。例如,使用权重来调整视图在容器中的相对大小或位置。

Absolute positioning(绝对定位):这是指使用数值坐标(如 x 和 y 坐标)来确定视图的位置。

Relative positioning(相对定位):这是指通过指定与其他视图的关系来确定视图的位置。

admin 发表于 2024-3-17 23:19:38

Spread chain
Packed chain
Spread inside chain
Packed chain with bias
Weighted chain
Spread chain(扩展链):在 ConstraintLayout 中,当一组视图以链的形式连接在一起时,可以使用 Spread chain 来指定它们之间的间隔。这将使得链中的视图在水平或垂直方向上均匀分布,并保持相等的间隔。

Packed chain(紧凑链):与 Spread chain 相反,Packed chain 会将链中的视图紧凑排列在一起,使它们之间的间隔最小化。这将使得链中的视图尽可能地靠近彼此。

Spread inside chain(链内扩展):当链中的视图的宽度或高度不相等时,可以使用 Spread inside chain 来指定它们之间的间隔。这将使得链中的视图在水平或垂直方向上均匀分布,并保持相等的间隔,同时考虑到视图的不同尺寸。

Packed chain with bias(带有偏移的紧凑链):与 Packed chain 类似,但可以通过设置 bias(偏移)来控制链中的视图在链的起始或结束位置的偏移程度。这可以用于在紧凑链中创建一定的偏移效果。

Weighted chain(权重链):在 ConstraintLayout 中,可以使用权重来调整链中视图的相对大小或位置。通过为链中的视图设置不同的权重值,可以实现视图在链中按比例分配空间的效果。

admin 发表于 2024-3-17 23:29:12

Spread chain,Elements are spread equally in space.
Packed chain,Elements are packed to use minimum space.
Spread inside chain,Elements are spread to use available space with head and tail attached to the parent.
Packed chain with bias,Elements are packed to use minimum space and are moved on their axis depending on bias.
Weighted chain,Elements are spread to use available space with head and tail attached to the parent.
Spread chain(扩展链):在 ConstraintLayout 中,当一组视图以链的形式连接在一起时,可以使用 Spread chain 来指定它们之间的间隔。这将使得链中的视图在水平或垂直方向上均匀分布,并保持相等的间隔。

Packed chain(紧凑链):与 Spread chain 相反,Packed chain 会将链中的视图紧凑排列在一起,使它们之间的间隔最小化。这将使得链中的视图尽可能地靠近彼此。

Spread inside chain(链内扩展):当链中的视图的宽度或高度不相等时,可以使用 Spread inside chain 来指定它们之间的间隔。这将使得链中的视图在水平或垂直方向上均匀分布,并保持相等的间隔,同时考虑到视图的不同尺寸。

Packed chain with bias(带有偏移的紧凑链):与 Packed chain 类似,但可以通过设置 bias(偏移)来控制链中的视图在链的起始或结束位置的偏移程度。这可以用于在紧凑链中创建一定的偏移效果。

Weighted chain(权重链):在 ConstraintLayout 中,可以使用权重来调整链中视图的相对大小或位置。通过为链中的视图设置不同的权重值,可以实现视图在链中按比例分配空间的效果。
页: [1]
查看完整版本: layouts