Probleme mit xml-Layout

phobos

Mitglied
Was muss ich tun damit Panel nur den Platz auf dem Bildschirm einnimmt der übrig bleibt? So wie es jetzt ist wird nur das erste Textview und dann bis zum Ende des Bildschirms Panel dargestellt. Die beiden anderen Textviews werden nicht mehr dargestellt.

[XML]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:eek:rientation="vertical" >

<TextView
android:id="@+id/azimuthAngle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Testtext" />

<org.phobos.kompass.Panel
android:id="@+id/panel1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

<TextView
android:id="@+id/rollAngle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />

<TextView
android:id="@+id/pitchAngle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />


</LinearLayout>[/XML]

Hier noch Panel, falls ich da auch was ändern muss:

Java:
package org.phobos.kompass;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;

public class Panel extends View {

	// Variablen deklarieren
	private int xpos; // Position der
	private int ypos; // Kugel
	private float pitch_angle; // Sensordaten
	private float roll_angle;
	private float azimuth_angle;

	// Konstruktor
	public Panel(Context context, AttributeSet attrs) {
		super(context, attrs);

	}

	// In der onDraw Methode wird auf den Bildschirm gezeichnet
	@Override
	public void onDraw(Canvas canvas) {


		// Hintergrund zeichnen
		Bitmap background = BitmapFactory.decodeResource(getResources(),
				R.drawable.background);
		Rect dst = new Rect();
		dst.set(0, 0, canvas.getWidth(), canvas.getHeight());
		canvas.drawBitmap(background, null, dst, null);

		// Kompass drehen und zeichnen
		Bitmap komp = BitmapFactory.decodeResource(getResources(),
				R.drawable.kom_blatt);
		Matrix mat = new Matrix();
		mat.postRotate(360 - azimuth_angle);
		Bitmap komp_gedr = Bitmap.createBitmap(komp, 0, 0, komp.getWidth(),
				komp.getHeight(), mat, true);
		int xversatz = (komp_gedr.getWidth() - komp.getWidth()) / 2;
		int yversatz = (komp_gedr.getHeight() - komp.getHeight()) / 2;
		canvas.drawBitmap(komp_gedr, canvas.getWidth() / 2 - komp.getWidth()
				/ 2 - xversatz, canvas.getHeight() / 2 - komp.getHeight() / 2
				- yversatz, null);

		// Kugelposition berechnen und zeichnen
		Bitmap kugel = BitmapFactory.decodeResource(getResources(),
				R.drawable.fadenkreuz);
		xpos = (canvas.getWidth() / 2)
				+ Math.round((roll_angle / 180) * canvas.getWidth())
				- kugel.getWidth() / 2;
		ypos = (canvas.getHeight() / 2)
				+ Math.round((pitch_angle / 180) * canvas.getHeight())
				- kugel.getHeight() / 2;
		canvas.drawBitmap(kugel, xpos, ypos, null);

	}

	// Getter und Setter

	public float getPitch_angle() {
		return pitch_angle;
	}

	public void setPitch_angle(float pitch_angle) {
		this.pitch_angle = pitch_angle;
	}

	public float getRoll_angle() {
		return roll_angle;
	}

	public void setRoll_angle(float roll_angle) {
		this.roll_angle = roll_angle;
	}

	public int getXpos() {
		return xpos;
	}

	public void setXpos(int xpos) {
		this.xpos = xpos;
	}

	public int getYpos() {
		return ypos;
	}

	public void setYpos(int ypos) {
		this.ypos = ypos;
	}

	public float getAzimuth_angle() {
		return azimuth_angle;
	}

	public void setAzimuth_angle(float azimuth_angle) {
		this.azimuth_angle = azimuth_angle;
	}

}
 

phobos

Mitglied
Funktioniert wunderbar: :applaus:

Java:
<?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:orientation="vertical" >

        <TextView
            android:id="@+id/azimuthAngle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Testtext" />

        <org.phobos.kompass.Panel
            android:id="@+id/panel1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1" />

        <TextView
            android:id="@+id/rollAngle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

        <TextView
            android:id="@+id/pitchAngle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />
    </LinearLayout>

</ScrollView>

Nur noch eine Verständnisfrage, wozu wird das Scrollview benötigt? Weils fillviewport bei LinearLayout nicht gibt?
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
F Layout mit listViews (Scrolling-Probleme) Android & Cross-Platform Mobile Apps 2
tfa Android Layout-Probleme: View programmatisch erweitern (addContentView) Android & Cross-Platform Mobile Apps 7
J Android Probleme mit BLE-Notify Android & Cross-Platform Mobile Apps 2
J Android Probleme mit der Realm Datenbank Android & Cross-Platform Mobile Apps 3
J Android Probleme mit Navigation-Fragments? Android & Cross-Platform Mobile Apps 0
N Probleme mit custom dynamic ListView Android & Cross-Platform Mobile Apps 15
B Android Probleme mit Android Studio Android & Cross-Platform Mobile Apps 6
B Android Probleme mit Realm Datenbank Android & Cross-Platform Mobile Apps 2
B Android Probleme mit ArrayList Android & Cross-Platform Mobile Apps 6
J Android Probleme mit FileProvider Android & Cross-Platform Mobile Apps 1
B Probleme mit Firebase Authentication Android & Cross-Platform Mobile Apps 25
H Android Probleme mit SearchView in ArrayAdapter Android & Cross-Platform Mobile Apps 7
ATZENPOWER Android Probleme mit mobilen Daten via lte Android & Cross-Platform Mobile Apps 10
S Android Probleme beim Verbinden mit einer HTTPS Seite Android & Cross-Platform Mobile Apps 4
B Android Probleme mit RealmObject? Android & Cross-Platform Mobile Apps 1
M Android ExpandableListView merkwürdige Probleme Android & Cross-Platform Mobile Apps 20
F Probleme mit Google-Maps Android & Cross-Platform Mobile Apps 0
B Android Probleme mit ViewPager? Android & Cross-Platform Mobile Apps 5
J Probleme mit ViewPager und Activity Android & Cross-Platform Mobile Apps 1
B Android Probleme mit Eclipse? Android & Cross-Platform Mobile Apps 6
E MAVLINK Probleme Android & Cross-Platform Mobile Apps 1
C Android Probleme mit JavaMail Android & Cross-Platform Mobile Apps 5
B Android Probleme mit Facebook-SDK? Android & Cross-Platform Mobile Apps 1
D Android Probleme mit info/warning (1, 902) Android & Cross-Platform Mobile Apps 4
D Android Gallery Probleme Android & Cross-Platform Mobile Apps 3
B Probleme mit App auf Galaxy S3? Android & Cross-Platform Mobile Apps 13
S Hat der AVD-Manager Probleme mit GPS? Android & Cross-Platform Mobile Apps 5
P Android Probleme mit Spinner Android & Cross-Platform Mobile Apps 3
A Android Probleme mit Dialog Android & Cross-Platform Mobile Apps 4
U SQLite-Datenbank Probleme Android & Cross-Platform Mobile Apps 8
T Android Probleme bei Facebook Integration Android & Cross-Platform Mobile Apps 5
A Probleme mit ListView / ArrayAdapter Android & Cross-Platform Mobile Apps 3
A Probleme mit Form.isShown Android & Cross-Platform Mobile Apps 9
A Probleme mit Calendar auf dem Handy Android & Cross-Platform Mobile Apps 3
U Probleme mit der drawString Methode bei Canvas Android & Cross-Platform Mobile Apps 8
P Probleme mit dem Deployment Android & Cross-Platform Mobile Apps 3
P Probleme mit Streams Android & Cross-Platform Mobile Apps 4
C 2 kleine Probleme (Datei lesen, String durchsuchen) Android & Cross-Platform Mobile Apps 16
G Proguard Obfuscator macht Probleme Android & Cross-Platform Mobile Apps 2
P Probleme mit RMS Android & Cross-Platform Mobile Apps 5
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
D Android Layout Problem Android & Cross-Platform Mobile Apps 2
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
W XML Layout: wann wird geladen? Android & Cross-Platform Mobile Apps 10
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
S Android Layout Problem mit fill_parent Android & Cross-Platform Mobile Apps 5

Ähnliche Java Themen

Neue Themen


Oben