我创建了一个自定义视图,扩展了AutoCompleteTextView。我也有与此相关的自定义属性。在布局中设置自定义字符串属性值时,约束布局设计屏幕预览停止正常工作。当我删除自定义字符串属性时,约束布局可以正常工作。这仅在设计时发生,在运行时没有问题。我重新安装并更新了Android Studio,但并没有帮助我。我的代码和屏幕截图如下:
broken view when setting custom attribute named model_field
attrs.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="DATV">
<attr name="model_field" format="string"/>
<attr name="search_type" format="enum">
<enum name="never" value="0"/>
<enum name="always" value="1"/>
<enum name="depended" value="2"/>
</attr>
</declare-styleable>
</resources>
Layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" 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">
<android.support.constraint.ConstraintLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- TODO: Update blank fragment layout -->
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/multiAutoCompleteTextView2"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView13"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/e_mail_adresi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView16" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView4"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView7"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView12"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/telefon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView17" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView3"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView8" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintTop_toBottomOf="@+id/textView11"
android:layout_marginTop="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/tc_kimlik_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView18" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView2"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<TextView
android:text="@string/arac_bilgileri"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/textView2"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="16dp" android:textStyle="bold"/>
<TextView
android:text="@string/marka"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView3" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/textView2" android:labelFor="@+id/carBrandDATV"/>
<tr.com.universe.raportiz.lib.views.CarBrandDATV
app:model_field="@string/CarBrand_name"
app:search_type="always"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/carBrandDATV"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView3"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"
/>
<TextView
android:text="@string/model"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView4" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/carBrandDATV"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
/>
<tr.com.universe.raportiz.lib.views.CarModelDATV
app:model_field="@string/CarModel_name"
app:search_type="depended"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/carModelDATV"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView4"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/plaka"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView6" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/carModelDATV" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"/>
<tr.com.universe.raportiz.lib.views.CarDATV
app:model_field="@string/Car_plate_no"
app:search_type="always"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/plateNoDATV"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView6"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/sasi_numaras"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView7" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/plateNoDATV" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"/>
<tr.com.universe.raportiz.lib.views.CarDATV
app:model_field="@string/Car_chassis_no"
app:search_type="always"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView5"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView7"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/motor_numarasi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView8" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView5"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<tr.com.universe.raportiz.lib.views.CarDATV
app:model_field="@string/Car_engine_no"
app:search_type="always"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView8"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/arac_sahibi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView9"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
android:layout_marginTop="8dp" android:textStyle="bold"/>
<TextView
android:text="@string/ad_soyad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView10" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/textView9" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView2"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView10"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/tc_kimlik_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView11" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView2"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView3" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintTop_toBottomOf="@+id/textView11"
android:layout_marginTop="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/telefon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView12" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView3"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView4"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView12"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/e_mail_adresi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView13" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView4"/>
<MultiAutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/multiAutoCompleteTextView"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView13"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/alici_bilgileri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView14" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/multiAutoCompleteTextView"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
android:textStyle="bold"/>
<TextView
android:text="@string/ad_soyad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView15" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/textView14"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView6" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/textView15" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/tc_kimlik_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView19" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView6"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView9" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/textView19" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/telefon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView20" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView9"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView10"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView20"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="@drawable/edittext_selector"/>
<TextView
android:text="@string/e_mail_adresi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView21" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/autoCompleteTextView10"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView11" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/textView21" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:background="@drawable/edittext_selector"/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
当我删除model_field
属性时,预览如下所示正常工作
the view when I remove the custom attributes named "model_field"