相关疑难解决方法(0)

Android约束布局奇怪的行为

我的约束布局的版本是1.0.0-alpha8.在我的布局中包含工具栏后,工具栏的左侧和右侧都有空间,如下图所示

在此输入图像描述

这是我的工具栏的代码

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/colorPrimary">


</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)

我已按照以下方式包含在我的布局中

<include
    layout="@layout/toolbar_top"
    android:id="@+id/topPanel"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"/>
Run Code Online (Sandbox Code Playgroud)

我没有在布局文件的根元素中使用任何额外的填充或边距.

另一个问题是,如果我编译或构建程序,我的代码会自动更改,例如

<include
    layout="@layout/toolbar_top"
    android:id="@+id/topPanel"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"/>
Run Code Online (Sandbox Code Playgroud)

改成

<include
    layout="@layout/toolbar_top"
    android:id="@+id/topPanel"
    android:layout_height="wrap_content"
    android:layout_width="368dp"/>
Run Code Online (Sandbox Code Playgroud)

并且指南还添加了一些我没有写的layout_editor_absoluteX附加值,比如自动添加.

<android.support.constraint.Guideline
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/guideline1"
    android:orientation="vertical"
    app:layout_constraintGuide_percent="0.15"
    tools:layout_editor_absoluteX="58dp"/>
Run Code Online (Sandbox Code Playgroud)

android android-constraintlayout

4
推荐指数
1
解决办法
9398
查看次数

标签 统计

android ×1

android-constraintlayout ×1