Dies ist mein erster Beitrag hier. Ich habe gerade Android-Programmierung gelernt und komme zu diesem Problem. Ich habe ein wenig gesucht und einige Lösungen gefunden, aber ich konnte meinen Code nicht funktionieren lassen. Ich möchte also wissen, welcher Teil meines Codes oder meiner Implementierung falsch ist.Wie man Android-Layout proportional unabhängig von Bildschirmgröße und Ausrichtung machen
Also, das Problem ist, ich möchte ein Layout, das auf verschiedenen Bildschirmgrößen und Ausrichtung bleibt das gleiche Verhältnis bleibt. Hier ist mein Code: „Sie müssen mindestens 10 Ruf Bilder schreiben“
activity_main.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="150dp" >
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="left"
android:id="@+id/textView1"/>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="right"
android:id="@+id/textView2"/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:id="@+id/textView3"/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="left"
android:id="@+id/textView4"/>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="center"
android:id="@+id/textView5"/>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:gravity="right"
android:id="@+id/textView6"/>
</LinearLayout>
<SeekBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/seekBar"
android:max="255"/>
</LinearLayout>
Ich kann nicht Screenshot zur Zeit veröffentlichen, weil es gesagt
Also, ich möchte den Bildschirm durch 3 Teile vertikal teilen, und teilen Sie den oberen Teil um 2 horizontal und den unteren Teil um 3 horizontal und behalten ihr Verhältnis unabhängig von Bildschirmgröße, Auflösung und Ausrichtung.
Der einzige Teil, der nicht funktionierte, ist der obere Block, auf den Code, den ich es auf android:layout_height="150dp"
, weil das Layout irgendwie gebrochen ist, wenn ich diese auf android:layout_height="fill_parent"
setzen. Aber das macht das Layout nicht proportional, wenn ich die Ausrichtung ändere. Jede Hilfe wird geschätzt.
Vielen Dank.
Sie sollten über 'LinearLayout' &' Gewicht' lesen! –
Wenn Sie 150dp Layout möchten, warum verwenden Sie Gewicht-Konzept für anderes Layout? –
Hallo, vielen Dank für den Hinweis. Ich habe das Problem jetzt gefunden. Ich habe diese auf 'android: layout_height =" fill_parent "' gesetzt, aber vergessen, das Gewicht einzustellen. Entschuldigung, ein Anfängerfehler. – Wellsen