Ich verwende Data Binding zum allerersten Mal. Alles funktionierte wie erwartet, bis ich beschloss, ein separates Layout für den Landscape-Modus zu erstellen. Nun, ich habe zwei Layouts für die Haupttätigkeit, die jeweils für Hoch- und Querformat:Android Data Binding für alternative Layouts erklärt unterschiedliche Root-Layout als Ansicht
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--Some Views-->
</LinearLayout>
</layout>
activity_main.xml (land):
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.constraint.ConstraintLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--Some Views-->
</android.support.constraint.ConstraintLayout>
</layout>
Das Problem ist, dass ich binding.mainLayout
nicht als ViewGroup
verwenden kann, weil es als eine Ansicht in ActivityMainBinding.java
deklariert ist:
public final android.view.View mainLayout;
Sollte es nicht als ViewGroup
erklärt werden, dass direkt verlängern ViewGroup
beide LinearLayout
und ConstraintLayout
zu sehen? Mache ich etwas falsch? Gibt es einen logischen Grund dafür oder ist es nur ein Versehen?
Danke dafür, aber ich bin nicht auf der Suche nach einer Problemumgehung (die ich in vielerlei Hinsicht sicher tun könnte). Ich bin neugierig auf den Grund für dieses Verhalten. –
Ich habe ein Problem in Google Ego Tracker erstellt: https://issuetracker.google.com/issues/62740925 Mal sehen, wie sie reagieren werden – Kamil