Skalierung für verschiedene Displayformate

  • 3 Antworten
  • Letztes Antwortdatum
S

simon.hess

Neues Mitglied
0
Hallo zusammen

Ich habe gerade angefangen mit meinem ersten eigenen App. Nun habe ich ein kleines Layout erstellt. Auf meinem Galaxy S3 mit 16:9 Bildschirmformat, wird das Layout aber falsch angezeigt. Wie kann ich die Objekte je nach Bildschirm richtig skalieren lassen? Hier noch die XML-Datei und ein Screenshot.

screenshot.PNG


Code:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/ScrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/youlodesign5"
    tools:context=".MainActivity" >

  <RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="152.5dip"
            android:layout_height="152.5dip"
            android:layout_marginLeft="5dip"
            android:layout_marginTop="5dip"
            android:src="@drawable/small"
            android:contentDescription="@null" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="152.5dip"
            android:layout_height="152.5dip"
            android:layout_marginLeft="162.5dip"
            android:layout_marginTop="5dip"
            android:src="@drawable/small"
            android:contentDescription="@null" />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="310dip"
            android:layout_height="152.5dip"
            android:layout_alignLeft="@+id/imageView1"
            android:layout_below="@+id/imageView1"
            android:layout_marginTop="5dip"
            android:src="@drawable/longitu"
            android:contentDescription="@null" />

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="152.5dip"
            android:layout_height="310dip"
            android:layout_alignLeft="@+id/imageView3"
            android:layout_below="@+id/imageView3"
            android:layout_marginTop="5dip"
            android:src="@drawable/high"
            android:contentDescription="@null" />

        <ImageView
            android:id="@+id/imageView5"
            android:layout_width="152.5dip"
            android:layout_height="152.5dip"
            android:layout_alignLeft="@+id/imageView2"
            android:layout_alignTop="@+id/imageView4"
            android:src="@drawable/small"
            android:contentDescription="@null" />

        <ImageView
            android:id="@+id/imageView6"
            android:layout_width="310dip"
            android:layout_height="310dip"
            android:layout_alignLeft="@+id/imageView4"
            android:layout_below="@+id/imageView4"
            android:layout_marginTop="5dip"
            android:src="@drawable/big"
            android:contentDescription="@null" />

        <ImageView
            android:id="@+id/imageView7"
            android:layout_width="310dip"
            android:layout_height="152.5dip"
            android:layout_alignLeft="@+id/imageView6"
            android:layout_below="@+id/imageView6"
            android:layout_marginTop="5dip"
            android:src="@drawable/longitu"
            android:contentDescription="@null" />

        <ImageView
            android:id="@+id/ImageView01"
            android:layout_width="152.5dip"
            android:layout_height="152.5dip"
            android:layout_above="@+id/imageView6"
            android:layout_alignRight="@+id/imageView6"
            android:src="@drawable/small"
            android:contentDescription="@null" />

    </RelativeLayout>

</ScrollView>
 
1. Probiers mal mit dp
2. Dannach versuch layout_weights und für die höhe wrap_content
 
Erstmal vielen Dank

Wie mache ich dann aber die Kacheln grösser oder kleiner, so dass sie passen? Das bekomme ich noch nicht wirklich hin.

Freundliche Grüsse
 
Also bin jetzt ein wenig weiter gekommen :biggrin:

Das Bild ist jetzt so eingestellt, dass es sich automatisch über die volle Breite erstreckt und mit dem FitYX füllt das rote Bild den Rahmen immer voll aus. Nun möchte ich aber, dass die ImageView immer ein gleich bleibendes Seitenverhältnis aufweist, also z.B 4:3. Wie kann ich das machen? Also die Höhe soll immer im selben Verhältnis zur Breite sein, auch wenn diese sich z.B. auf einem Tablet ändert.

Vieln Dank schon im Voraus und freundlcihe Grüsse

P.S: hier noch Code und ein Screenshot

Code:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/ScrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    android:paddingBottom="5dp"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingTop="5dp"
    tools:context=".MainActivity" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="1000dp"
        android:layout_gravity="center_vertical|fill_horizontal|top" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="fill_parent"
            android:layout_height="210dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="0dp"
            android:scaleType="fitXY"
            android:src="@drawable/breit" />

    </RelativeLayout>

</ScrollView>

screenshot.PNG
 
Zurück
Oben Unten