Android Layout Problem mit fill_parent

Swoop

Gesperrter Benutzer
Hallo,

ich hab ein Problem mit dem Layout in Android. Und zwar würde ich gerne einen Spinner (mit fester Höhe) dann einen Webview, der den Platz nehmen soll, welcher noch übriig bleibt und am schluss soll dann noch eine Progressbar angezeigt werden.

Allerdings fehlt mir jetzt irgendwie einen Möglichkeit, dass die ProgressBar dargestellt wird, ohne damit der Platz des Webviews berechnet werden muss.

Hier mal meine XML:

[XML]<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:eek:rientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#000000">
<ImageView android:id="@+id/logo" android:layout_width="fill_parent"
android:layout_height="20dip" android:src="@drawable/qtvx_logo"
android:gravity="center" android:background="@drawable/mygradient"
android:layout_marginRight="4px" android:layout_marginLeft="3px" />
<Spinner android:id="@+id/spinner" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<WebView android:id="@+id/webview" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_marginTop="-4px"
android:layout_marginRight="4px" android:layout_marginLeft="3px"
android:layout_marginBottom="4px" />
<ProgressBar android:indeterminate="false"
style="?android:attr/progressBarStyleHorizontal" android:layout_width="fill_parent"
android:progress="50" android:progressDrawable="@drawable/progress_style"
android:layout_height="10dip" android:id="@+id/progressbar"
android:layout_marginRight="4px" android:layout_marginLeft="3px"
android:layout_marginBottom="4px" android:layout_marginTop="-4px" />
</LinearLayout>
[/XML]

Mir ist klar dass es momentan an dem Fill_Parent liegt. aber ich würde gerne wissen, obs da ne einfache Möglichkeit gibt?

Grüße und Danke Swoop
 

schlingel

Gesperrter Benutzer
2 Möglichkeiten sehe ich da:

Entweder du arbeitest mit einem TableLayout über dass du Verhältnisse verwenden kannst oder du verwendest wrapcontent für deine Webview.

Aber ich schätze du möchtest den ganzen Bildschirm ausfüllen und dabei die Webview als dynamisch wachsendes Element haben mit einem Element darunter mit fester Höhe. Also fährst du mit dem TabeLayout besser als mit dem LinearLayout.
 

Swoop

Gesperrter Benutzer
Soo jetzt hab ich das TableLayout eingebaut. Allerdings zeigt er meinen WebView jetzt nicht mehr über die komplette Zeile -.-

[XML]<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:stretchColumns="0">
<TableRow>
<ImageView android:id="@+id/logo" android:layout_width="fill_parent"
android:layout_height="20dip" android:src="@drawable/qtvx_logo"
android:gravity="center" android:background="@drawable/mygradient"
android:layout_marginRight="4px" android:layout_marginLeft="3px" />
</TableRow>
<TableRow>
<Spinner android:id="@+id/spinner" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow android:layout_height="fill_parent">
<WebView android:id="@+id/webview" android:layout_marginTop="-4px"
android:layout_marginRight="4px" android:layout_marginLeft="3px"
android:layout_marginBottom="4px" />
</TableRow>
<TableRow>
<ProgressBar android:indeterminate="false"
style="?android:attr/progressBarStyleHorizontal" android:progress="100"
android:progressDrawable="@drawable/progress_style"
android:layout_height="5dip" android:id="@+id/progressbar"
android:layout_marginRight="4px" android:layout_marginLeft="3px"
android:layout_marginBottom="4px" />
</TableRow>
</TableLayout>[/XML]

Hier gehts zu nem Bild!


Edit:

Ich habe es mit einem RelativeLayout lösen können ...
 
Zuletzt bearbeitet:

schlingel

Gesperrter Benutzer
Hallo,

da hab ich mich etwas vertan. Habe mich gerade selbst ein wenig mit der Aufgabenstellung gespielt und bin zu folgender Lösung gekommen:

[xml]
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:eek:rientation="vertical">
<LinearLayout android:layout_height="75px"
android:layout_width="fill_parent"
android:background="#336699" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#FF0000" />
<LinearLayout android:layout_height="75px"
android:layout_width="fill_parent"
android:background="#00FF00" />
</LinearLayout>
</ScrollView>
[/xml]

Wichtig ist dabei, das android:fillViewport="true" der ScrollView und das android:layout_weight="1" des wachsenden Controls.

Wie das ganze auf meinem HTC Wildfire aussieht hab ich dir als Bild angehängt.
 

Anhänge

  • device_screenshot.png
    device_screenshot.png
    4,7 KB · Aufrufe: 38

Swoop

Gesperrter Benutzer
Hm okay danke... also ich habe es gerade mit einem RelativeLayout lösen können... Allerdings wär mir deine Lösung lieber gewesen... aber naja jetzt hab ich es schon geändert...

Aber für die Zukunft ist es auf jeden Fall eine Interessante herangehensweise
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
D Android Layout Problem Android & Cross-Platform Mobile Apps 2
W Ausklappbares Verlängertes XML Layout Android & Cross-Platform Mobile Apps 6
W Android Wieso kann ich keine ListView mehr zum Layout hinzufügen? Android & Cross-Platform Mobile Apps 1
A Android-Studio: 2. Layout nach kurzer Zeit aufzeigen Android & Cross-Platform Mobile Apps 2
S Android Layout - welchen Typ? Android & Cross-Platform Mobile Apps 3
B Android Multiple Screens- layout-sw600dp Android & Cross-Platform Mobile Apps 1
D Android Layout für alle Geräte Android & Cross-Platform Mobile Apps 4
W Android Designfrage / Layout / Activity / Fragments Android & Cross-Platform Mobile Apps 2
B Layout Bibliothek Android & Cross-Platform Mobile Apps 8
B Android Spiele-Layout umsetzen Android & Cross-Platform Mobile Apps 5
O zurück Schaltfläche in voriges Layout Android & Cross-Platform Mobile Apps 5
B Erste Android-App: setContentView(R.layout.main) funktioniert nicht Android & Cross-Platform Mobile Apps 6
D Android Viele Buttons und ein Layout Android & Cross-Platform Mobile Apps 6
M Android Game, welche Layout? Android & Cross-Platform Mobile Apps 2
B Eigene View xml-Layout einbinden Android & Cross-Platform Mobile Apps 1
R Android Layout Bild mit Text Android & Cross-Platform Mobile Apps 13
K Rand bei (Table,Relative,Linear)Layout - wie bekomme ich ihn weg? Android & Cross-Platform Mobile Apps 3
P Android Nach Animation Layout auf alten Platz Android & Cross-Platform Mobile Apps 3
T Android Layout Update Animation Android & Cross-Platform Mobile Apps 3
P Probleme mit xml-Layout Android & Cross-Platform Mobile Apps 2
W XML Layout: wann wird geladen? Android & Cross-Platform Mobile Apps 10
F Layout mit listViews (Scrolling-Probleme) Android & Cross-Platform Mobile Apps 2
G Fehlermeldung: "No XML content. Please add a root view or layout to your documet." Android & Cross-Platform Mobile Apps 7
N Android xml - graphical layout nur noch weiß :o Android & Cross-Platform Mobile Apps 4
T Android Merkwürdigkeiten im Layout Android & Cross-Platform Mobile Apps 7
JAVAnnik Android Layout ändern in Thread Android & Cross-Platform Mobile Apps 2
A Android Browser öffnen, XML-GUI-Layout Android & Cross-Platform Mobile Apps 23
A Absolute Layout soll auf jedem Gerät gleich aussehen Android & Cross-Platform Mobile Apps 4
tfa Android Layout-Probleme: View programmatisch erweitern (addContentView) Android & Cross-Platform Mobile Apps 7
W Prüfen, ob App auf Gerät installiert ist Problem S10 Android & Cross-Platform Mobile Apps 11
W In App Purchase Problem? Android & Cross-Platform Mobile Apps 36
W Problem mit Android Studio Android & Cross-Platform Mobile Apps 0
T Android R.string.test+i Problem Android & Cross-Platform Mobile Apps 2
K Android to Pi | Websocket Problem Android & Cross-Platform Mobile Apps 3
N Intent und finish() Problem Android & Cross-Platform Mobile Apps 5
B Android App Programmierung Einsteiger Problem Android & Cross-Platform Mobile Apps 4
emeraldo Android Problem mit Bottomnavmenu Android & Cross-Platform Mobile Apps 10
I Das Problem mit der Tastatur... android:windowSoftInputMode="adjustPan" Android & Cross-Platform Mobile Apps 1
M Android App → Problem mit dem Speichern von einem Bitmap–Objekt. Android & Cross-Platform Mobile Apps 1
A Android Android Studio Emulator Problem Android & Cross-Platform Mobile Apps 1
S Android Studio Bluetooth App Problem Android & Cross-Platform Mobile Apps 6
J TicTacToe Problem bei kontrolle Android & Cross-Platform Mobile Apps 7
J Button array ID Problem Android & Cross-Platform Mobile Apps 2
M Problem bei Werteübergabe, MSQL verbindung Android & Cross-Platform Mobile Apps 3
S Android Problem mit Android Virtual Device erstellung. Android & Cross-Platform Mobile Apps 2
Anfänger2011 Text to Speech Problem Android & Cross-Platform Mobile Apps 1
S Android Android java onclick listener Problem Android & Cross-Platform Mobile Apps 9
A Android Problem mit ListView und OnItemClickListener.. Android & Cross-Platform Mobile Apps 10
K Problem mit arraylist und button Android & Cross-Platform Mobile Apps 16
R W-Lan Problem über Sockets Android & Cross-Platform Mobile Apps 1
P ViewPager Problem Android & Cross-Platform Mobile Apps 1
A Android Problem mit Video von Youtube abspielen Android & Cross-Platform Mobile Apps 4
A Android Problem mit Zurücktaste und ausgabe der Aktuellen Seite Android & Cross-Platform Mobile Apps 6
B Android Problem mit Soundwiedergabe Android & Cross-Platform Mobile Apps 2
T Android Android Sensor: Java Problem Android & Cross-Platform Mobile Apps 1
G Problem beim Rendern von 3D-Objekt Android & Cross-Platform Mobile Apps 0
L Android Gyroscope Sensor Problem Android & Cross-Platform Mobile Apps 2
S Android GPS Problem Android & Cross-Platform Mobile Apps 24
J Eclipse Emulator Problem Android & Cross-Platform Mobile Apps 1
J Eclipse Emulator Problem Android & Cross-Platform Mobile Apps 0
B Android Problem mit Rückgabewert Android & Cross-Platform Mobile Apps 13
L Android komisches Bitmap-Größe-Problem Android & Cross-Platform Mobile Apps 8
R Problem mit View in ScrollView Android & Cross-Platform Mobile Apps 6
R Eclipse + AndroidSDK - Problem mit Referenzen Android & Cross-Platform Mobile Apps 6
M Problem mit setOnClickListener Android & Cross-Platform Mobile Apps 4
DaniSahne96 Problem beim Appdebuggen auf Smartphone Android & Cross-Platform Mobile Apps 3
P Android Problem beim Widget - Denkfehler ? Android & Cross-Platform Mobile Apps 2
M GCM IntentService Problem Android & Cross-Platform Mobile Apps 3
D Android Gallery Problem Android & Cross-Platform Mobile Apps 5
P Problem mit Cell id Android & Cross-Platform Mobile Apps 6
L Android Problem mit "spinner" Android & Cross-Platform Mobile Apps 10
D Android problem mit geschwindigkeitsberechnung app Android & Cross-Platform Mobile Apps 2
E Android Problem mit Contact Provider Android & Cross-Platform Mobile Apps 1
H Android Problem mit ListActivity Android & Cross-Platform Mobile Apps 3
F Android ExpandableList, SimpleCursorTreeAdapter, Cursor Problem Android & Cross-Platform Mobile Apps 2
A Android Problem mit Long.getLong() bzw. Integer.getInteger() Android & Cross-Platform Mobile Apps 2
A Problem mit HTTP- Verbindung Android & Cross-Platform Mobile Apps 4
V [Java] und [JavaME] ClientServer StreamConnection . Problem beim lesen / schreiben Android & Cross-Platform Mobile Apps 2
F Eclipse JAD File erzeugen -- Problem Android & Cross-Platform Mobile Apps 10
R Ein Problem beim ausführen von folgendem Quelltext Android & Cross-Platform Mobile Apps 11
M Problem mit dem Auslesen von System Properties Android & Cross-Platform Mobile Apps 7
P wtk problem Android & Cross-Platform Mobile Apps 3
G Math exp() Problem Android & Cross-Platform Mobile Apps 4
G S40 Problem Android & Cross-Platform Mobile Apps 8
A Problem beim Subtrahieren eines Double von einem Double Android & Cross-Platform Mobile Apps 5
C Problem Device/Emulator wird nicht erkannt Android & Cross-Platform Mobile Apps 3
S Image Problem Android & Cross-Platform Mobile Apps 11
M Problem mit den Softkeys Android & Cross-Platform Mobile Apps 4
G J2ME jar-problem Android & Cross-Platform Mobile Apps 10
S Komisches Problem Android & Cross-Platform Mobile Apps 3
F Problem beim Erstellen der Jar File Android & Cross-Platform Mobile Apps 4
A Problem: Canvas-Grösse Motorola RAZR v3r Android & Cross-Platform Mobile Apps 8
S Problem mit Einbindung einer externer Bibliothek Android & Cross-Platform Mobile Apps 2
G Random - Problem Android & Cross-Platform Mobile Apps 5
E problem mit den resourcen Android & Cross-Platform Mobile Apps 2
O Problem mit Datagramconnection Android & Cross-Platform Mobile Apps 2
P Problem mit der Uhrzeit Android & Cross-Platform Mobile Apps 2
S Problem auf dem Handy Android & Cross-Platform Mobile Apps 3

Ähnliche Java Themen

Neue Themen


Oben