Layout unabhängig von screen size

  • 4 Antworten
  • Letztes Antwortdatum
P

Paul16

Neues Mitglied
0
Hallo zusammen,

ich probiere nun schon eine ganze Weile rum, lese mich durch foreneinträge und finde einfach keine Lösung für mein Problem:

Ich habe eine LinearLayout, das aus 4 RelativeLayouts besteht. In diesen RelativeLayouts gibt es einige TextViews und SeekBars.

Die ganze Geschichte ist durch Verwendung von wrap_content und dp bzw. sp auflösungsunabhängig.

Auf einem 4.3" screen ist alles perfekt.
Wenn ich die App nun aber auf einem normalen screen von 4.0" laufen lasse, wird am unteren Bildschirmrand etwas abgeschnitten.
Das liegt meiner meinung nach daran, dass einfach nicht genug platz auf dem bildschirm für alle wrap_contents ist und dann der letzte "verliert".
durch die textSize=??sp wird die textgröße unabhängig von der auflösung, aber nimmt auf einem kleineren screen dann prozentual zum insgesamt verfügbaren platz mehr raum ein, oder?

wie kann ich das problem beheben und die textgröße von der bildschirmgröße abhängig machen? d.h. ein bestimmter text geht z.b. immer bis zu bildschirmmitte.

vielen dank euch schon einmal fürs draufgucken!
ich hoffe ihr könnt mir helfen

liebe grüße
paul

hier einmal(etwas gekürzt) meine layout-datei:
Code:
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/azure2" >
       
    <RelativeLayout 
        android:id="@+id/rlTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp" >
       
        <ImageView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/titel"
            android:adjustViewBounds="true"
            android:scaleType="centerCrop" />        
    </RelativeLayout>
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/azure3"
        android:layout_margin="5dp" >
        
        <TextView 
            android:id="@+id/radioText"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:textAppearance="@style/TextAppearLayoutM"
            android:layout_alignParentLeft="true" />
        <RadioGroup
            android:id="@+id/radioGroup"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_below="@id/radioText"
            android:layout_marginBottom="15dp"
            android:layout_centerInParent="true" >
            <RadioButton
                android:id="@+id/rbSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/small"
                android:textAppearance="@style/TextAppearLayoutM" />    
            <RadioButton
                android:id="@+id/rbMedium"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/medium"
                android:textAppearance="@style/TextAppearLayoutM" />
            <RadioButton 
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:id="@+id/rbBig"
                android:layout_weight="1"
                android:text="@string/big"
                android:textAppearance="@style/TextAppearLayoutM" />
            <RadioButton
                android:id="@+id/rbEnd"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/end"
                android:textAppearance="@style/TextAppearLayoutM" />
        </RadioGroup>
        
        <TextView
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:textAppearance="@style/TextAppearLayoutM"
            android:layout_below="@id/radioGroup" />    
        <SeekBar
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            ... />
           <TextView
            android:id="@+id/tvRA" 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:textAppearance="@style/TextAppearLayoutM"
            .../>  
        <SeekBar
            android:id="@+id/sbRA"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
           ... />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ...
            android:textAppearance="@style/TextAppearLayoutM" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ...
            android:textAppearance="@style/TextAppearLayoutM" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            ... />
        
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           ..." />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           ... />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ..." />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ... />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           .../>
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
         ... >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ... />

        <SeekBar
            android:id="@+id/sbGericht"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            ..." />
        
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           ... />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ... />
    </RelativeLayout>
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginBottom="5dp"
        android:background="@color/darkblue" >
        
        <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="2dp"
            android:textSize="12dp"
            android:textColor="@color/azure3"
            android:text="@string/personal"/>
    
    </RelativeLayout>    
      
</LinearLayout>
 
Hi Paul,

schau dir mal fragments an.
Ich denke das dürfte dein Problem beheben.

Mfg

pootney
 
Hey pootney !

Danke für deine antwort.

Mein ziel ist es auch auf relativ kleinen screens, das volle layout anzeigen zu lassen, indem sich die Schriftgröße und damit auch die Größe der einzelnen textviews automatisch an die Bildschirmgröße anpasst, sodass alles genau auf den Bildschirm passt.

Mit fragments wird erreicht, dass bei kleineren Bildschirmen einzelne fragments nicht direkt angezeigt werden oder liege ich da falsch?

Hab ich fragments noch nicht ganz verstanden und lässt sich mein problem doch mit ihnen lösen?
Noch sehe icj nicht den vorteil den fragments mir in meinem fall bringen.
Liebe Grüße, paul
 
Mein Vorschlag ist eine Scrollview drum zu bauen. Du wirst es nie so hinkriegen, dass es auf allen Screens formatfüllend ist. Du bezeichnest jetzt 4" als "klein". Es sind aber immer noch einige 3.2 oder 3.7" Geräte auf dem Markt (Einsteigergeräte)
 
Hi Paul,

da ich gerade mit Android Entwicklung angefangen habe weiß ich das leider selber nicht genau :D.
In meinen speziellen Fall mit der Kombination einiger Bibliotheken hat es aber geholfen.

Mfg

pootney
 
Zurück
Oben Unten