ConstraintLayout不适用于某些小部件

时间:2017-08-08 04:58:51

标签: android

我正在使用ConstraintLayout,但在某些设备中,它无法正常工作。所有小部件都在ConstraitLayout内部正常工作,但只有1个小部件虚线曲线不能放在正确的位置。

这张照片来自GenyMotion三星S2 4.1.1 enter image description here

这张照片来自GenyMotion Nexus5x 6.0.0 enter image description here

已更新

 <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clipToPadding="false"
    android:background="@drawable/direction_bg"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        android:layout_width="40dp"
        android:layout_height="100dp"
        android:layerType="software"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:id="@+id/arc"
        android:background="#88000000"
        android:orientation="vertical">

    </LinearLayout>


    <ImageView
        android:layout_width="@dimen/home_plane_size"
        android:layout_height="@dimen/home_plane_size"
        app:srcCompat="@drawable/ic_plane"
        android:id="@+id/plane"
        android:rotation="-65"
        app:layout_constraintLeft_creator="1"
        app:layout_constraintTop_creator="1"
        app:layout_constraintRight_creator="1"
        app:layout_constraintBottom_creator="1"
        android:background="#88000000"
        app:layout_constraintLeft_toLeftOf="@+id/guideline1"
        app:layout_constraintRight_toRightOf="@+id/guideline1"
        app:layout_constraintBottom_toTopOf="@+id/from_point"/>
    <ImageView
        android:layout_width="@dimen/home_point_icon_size"
        android:layout_height="@dimen/home_point_icon_size"
        app:srcCompat="@drawable/ic_radio_button"
        android:id="@+id/from_point"
        app:layout_constraintLeft_creator="1"
        app:layout_constraintTop_creator="1"
        app:layout_constraintRight_creator="1"
        app:layout_constraintBottom_creator="1"
        android:background="#88000000"
        app:layout_constraintLeft_toLeftOf="@+id/guideline1"
        app:layout_constraintRight_toRightOf="@+id/guideline1"
        app:layout_constraintTop_toTopOf="@+id/arc"
        app:layout_constraintBottom_toBottomOf="@+id/arc"/>
    <ImageView
        android:layout_width="@dimen/home_point_icon_size"
        android:layout_height="@dimen/home_point_icon_size"
        app:layout_constraintLeft_creator="1"
        app:layout_constraintTop_creator="1"
        app:layout_constraintRight_creator="1"
        app:layout_constraintBottom_creator="1"
        android:background="#88000000"
        app:srcCompat="@drawable/ic_radio_button"
        app:layout_constraintLeft_toLeftOf="@+id/guideline2"
        app:layout_constraintRight_toRightOf="@+id/guideline2"
        app:layout_constraintTop_toTopOf="@+id/arc"
        app:layout_constraintBottom_toBottomOf="@+id/arc"
        android:id="@+id/ep"/>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:id="@+id/guideline1"
        app:layout_constraintLeft_creator="1"
        app:layout_constraintTop_creator="1"
        app:layout_constraintRight_creator="1"
        app:layout_constraintBottom_creator="1"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/guideline2" />
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:id="@+id/guideline2"
        app:layout_constraintLeft_creator="1"
        app:layout_constraintTop_creator="1"
        app:layout_constraintRight_creator="1"
        app:layout_constraintBottom_creator="1"
        app:layout_constraintLeft_toRightOf="@id/guideline1"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"/>

</android.support.constraint.ConstraintLayout>

黑色矩形的左侧必须是屏幕的中心。 enter image description here

0 个答案:

没有答案