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"
androidrientation="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:
[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"
androidrientation="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;
}
}