Ngu*_*HCM 9 android android-layout android-studio android-constraintlayout
我正在尝试使用Constraint Layout.在Gradle构建成功完成.但我得到了"安装APK时出错",代码如下:
无法完成会话:INSTALL_FAILED_INVALID_APK:已多次定义拆分lib_slice_0_apk
这是我的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/app_bar_main">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="B?n c?m th?y th? nào" />
<Button
android:id="@+id/checkSicknessBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Ki?m tra"
android:textColor="@android:color/holo_blue_light"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#9ed7ec"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/content_margin"
android:src="@drawable/baseline_access_alarm_white_48" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Gi? u?ng thu?c s?p t?i 15:30"
android:textAlignment="center"
android:textColor="#f29d15"
android:textSize="20dp"
android:textStyle="bold" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/baseline_keyboard_arrow_right_white_48" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:background="#9ed7ec"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/content_margin"
android:src="@drawable/baseline_event_white_48" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="L?ch h?n s?p t?i\n 29/2/2018 8:00"
android:textAlignment="center"
android:textColor="#f29d15"
android:textSize="20dp"
android:textStyle="bold" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/baseline_keyboard_arrow_right_white_48" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
app:layout_constraintBottom_toTopOf="@+id/linearLayout9"
app:layout_constraintTop_toTopOf="@+id/linearLayout9">
<LinearLayout
android:id="@+id/linearLayout11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="53dp"
android:layout_marginStart="53dp"
android:layout_weight="1"
android:background="#9ed7ec"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/baseline_history_white_48" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="L?ch s?\n khám b?nh"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="56dp"
android:layout_marginRight="56dp"
android:layout_weight="1"
android:background="#9ed7ec"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/baseline_insert_chart_outlined_white_48" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="K?t qu? c?n\n lâm sàng"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin">
<LinearLayout
android:id="@+id/linearLayout13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="53dp"
android:layout_marginStart="53dp"
android:layout_weight="1"
android:background="#9ed7ec"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/baseline_history_white_48" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="L?ch s?\n khám b?nh"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="56dp"
android:layout_marginRight="56dp"
android:layout_weight="1"
android:background="#9ed7ec"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/baseline_insert_chart_outlined_white_48" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="K?t qu? c?n\n lâm sàng"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
我首先在sub中获得了关于"View constraint"的错误代码
<LinearLayout></LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我通过使用推断约束来修复它.我是Android Layout的新手,我正在努力制作响应式布局Constraint Layout.请帮我解决这个问题.