7

我刚刚更新了我android studio2.2 Preview 3并尝试了新的constraint layout我在布局中放置了一个edittext并在我的手机上运行了应用程序但这就是我得到的

例子

然后我尝试将代码转换constraint layout回之前的代码constraint layout,结果是一样的。

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.ellohinc.constrainttest.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main"/>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

content_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/content_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_main"
    tools:context="com.ellohinc.constrainttest.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="@+id/content_main"
        app:layout_constraintLeft_toLeftOf="@+id/content_main"
        app:layout_constraintRight_toRightOf="@+id/content_main"
        app:layout_constraintTop_toTopOf="@+id/content_main" />

    </android.support.constraint.ConstraintLayout>

请任何帮助将不胜感激。

4

2 回答 2

3

我遇到过同样的问题。我通过降级 gradle 版本解决了这个问题。它会停止即时运行。

于 2016-06-21T09:14:14.023 回答
0

在您的gradle文件中将您的依赖项下的 gradle 版本更改为像这样的较低版本com.android.tools.build:gradle:2.0.0。这个对我有用。

于 2016-07-07T11:39:32.493 回答