Ich habe eine ListView
, die zwei Elemente in einer Zeile anzeigt. Die View
die eine Zeile angezeigt hat eine LinearLayout
wie es Wurzel ist:Layoutgewichte in Android LinearLayout funktionieren nicht richtig
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<LinearLayout
android:id="@+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/grey"
android:gravity="center_vertical">
<TextView
android:id="@+id/textview1"
style="@style/refinement_button"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="@color/white"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<LinearLayout
android:id="@+id/layout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/grey"
android:gravity="center_vertical">
<TextView
android:id="@+id/textview2"
style="@style/refinement_button"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="@color/white"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
im Editor im Android Studio I
sehenaber auf einem Gerät, ich sehe
(Bild im Editor neu erstellt, um Zeit zu sparen)
Ich habe dies auf einem Nexus6 mit Android 7.0 und auf einem Nexus 5 mit Android 6.0.1 versucht. Ich nehme an, das ist ein Fehler in Android auf den Telefonen oder im Editor in Android Studio. Der Zweck des Editors ist es, Ihnen zu zeigen, wie Ihr Layout auf einem Gerät aussieht.
Ich frage nicht um Rat, wie man ein richtiges Layout erstellt. Mein einziger Punkt ist, dass sich das, was auf meinem Gerät angezeigt wird, von dem unterscheidet, was ich im Editor in Android Studio sehe, und ich frage mich, warum.
Sie stellen eine Frage und beantworten sie sofort selbst in der gleichen Minute .... Was ist der Sinn dafür? – Opiatefuchs
Wenn Sie eine Frage zu stackoverflow stellen, schlägt stackoverflow vor, dass Sie sofort "Q & A style" beantworten. Ich habe viel Zeit damit verbracht, die Lösung zu finden, konnte das Problem hier nicht finden, also teile ich es mit anderen. – Christine
@Opiatefuchs Und hier ist ein [Beispiel] (http://stackoverflow.com/questions/23353173/unidymy-myapp-has-stopped-how-can-i-solve-this) von einem solchen Fall, den Sie wahrscheinlich wissen. – Onik