2017-12-05 13 views
2

내 위젯에 constraintLayout을 사용하려하지만 라인 0에서 오류가 발생했습니다 (xml은 라인 1에서 시작하지 않습니까?). 여기 제약 레이아웃을 사용하는 위젯

코드입니다 :

<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:background="#FFF" 
    android:padding="@dimen/widget_margin"> 


    <TextView 
     android:id="@+id/appwidget_text" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:layout_margin="8dp" 
     android:layout_marginBottom="8dp" 
     android:layout_marginEnd="8dp" 
     android:layout_marginStart="8dp" 
     android:layout_marginTop="8dp" 
     android:background="#09C" 
     android:text="@string/appwidget_text" 
     android:textColor="#ffffff" 
     android:textSize="24sp" 
     android:textStyle="bold|italic" 
     android:gravity="center" 
     app:layout_constraintBottom_toTopOf="@+id/split2" 
     app:layout_constraintEnd_toEndOf="parent" 
     app:layout_constraintHorizontal_bias="0.501" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     tools:contentDescription="@string/appwidget_text"/> 

    <Button 
     android:id="@+id/flip" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:layout_marginBottom="8dp" 
     android:layout_marginStart="8dp" 
     android:text="@string/show_answer" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintEnd_toStartOf="@+id/split" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/split2" /> 

    <Button 
     android:id="@+id/next" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:layout_marginBottom="8dp" 
     android:layout_marginEnd="8dp" 
     android:text="@string/next_question" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintEnd_toEndOf="parent" 
     app:layout_constraintStart_toStartOf="@+id/split" 
     app:layout_constraintTop_toBottomOf="@+id/split2" /> 

    <android.support.constraint.Guideline 
     android:id="@+id/split" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     app:layout_constraintGuide_percent="0.5" /> 

    <android.support.constraint.Guideline 
     android:id="@+id/split2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     app:layout_constraintGuide_percent="0.75" /> 

</android.support.constraint.ConstraintLayout> 

오류 :

Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.constraint.ConstraintLayout

참고 : 내가 선형 레이아웃을 사용하여 시도하고 일했다,하지만 난 constraintLayout를 사용하여 수행하는 것을 선호합니다.

+0

"위젯"이란 [ "app widget"] (https://developer.android.com/guide/topics/appwidgets/index.html)을 의미합니까? – CommonsWare

+0

예, https://developer.android.com/design/patterns/widgets.html이 –

답변