4
我的约束布局的版本是1.0.0-alpha8
。之后,我已经包括在我的布局工具栏,则在工具栏的左边和右边两个空间,像下面Android约束布局奇怪行为
这里将图像的代码,我的工具栏
<?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>
我在以下方式中包含在我的布局中
<include
layout="@layout/toolbar_top"
android:id="@+id/topPanel"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
我没有在布局文件的根元素中使用任何其他填充或边距。
另一个STANGE的事情是,如果我编译或构建程序我的代码自动改变,像
<include
layout="@layout/toolbar_top"
android:id="@+id/topPanel"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
更改为
<include
layout="@layout/toolbar_top"
android:id="@+id/topPanel"
android:layout_height="wrap_content"
android:layout_width="368dp"/>
而且指南还添加我没有一些额外的价值写,就像自动添加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"/>
目标SDK和哪个主题正在使用? –
@AnkitaShah targetSdkVersion 24 and theme is Theme.AppCompat.Light.NoActionBar –
试试这个 'Toolbar parent =(Toolbar)customView.getParent(); parent.setPadding(0,0,0,0); //对于标签,否则给标签空间 parent.setContentInsetsAbsolute(0,0);' 或者检查这个 http://stackoverflow.com/a/28086802/6005977 –