Breite setzen in Custom Component

K

krackmoe

Neues Mitglied
1
An der oberen Bildschirmkante befinden sich 2 TextViews, eins Links eins Rechts.
Das Funktioniert wunderbar.

Jetzt möchte ich aber, dass das GameWindow wenn ich den Screen drehe, sich nicht mehr über die volle Breite erstreckt, sondern mittig zentriert ist.
Wie mach ich das!? :/

Code:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content">
    
    <LinearLayout         xmlns:android="http://schemas.android.com/apk/res/android"
    	android:id="@+id/content"
    	android:layout_width="fill_parent"
    	android:layout_height="wrap_content"
    	android:orientation="horizontal">
	    
	    <TextView  
			android:id="@+id/firstPlayer"
			android:layout_width="wrap_content"
		    android:layout_height="wrap_content" 
		    android:text="@string/firstPlayer"
		    android:textColor="#ffffff"
		    android:layout_gravity="left"/>
		    
		    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    	android:layout_width="fill_parent"
			    android:layout_height="wrap_content"
			    android:orientation="horizontal"
			    android:gravity="right" >
			    <TextView 	    	 
					android:id="@+id/secondPlayer"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content" 
				    android:text="@string/secondPlayer"
				    android:textColor="#ffffff"
				    android:layout_gravity="right"/>
		    </LinearLayout>
	</LinearLayout>
	
	<com.tictactoe.GameWindow 
		android:id="@+id/game_window" 
		android:layout_height="wrap_content"
		android:layout_width="wrap_content"
		android:background="#FFFFFF"
		android:layout_below="@+id/content"
		android:layout_centerHorizontal="true"/>
</RelativeLayout>
 
ein Layout für Hochkantmodus und ein Layout für Breitbildmodus?
 
Naja, die Frage ist eher.
Wie ich mein Spielfenster in die Mitte bekomme...
Das weiße rundherum geht bis an den Rand. Aber das Spielfenster soll Mittig sein und das krieg ich nicht hin..
 
Klingt nach einem Fall für onMeasure() überladen.
 

Ähnliche Themen

A
Antworten
1
Aufrufe
634
swa00
swa00
5
Antworten
0
Aufrufe
743
539901
5
D
Antworten
23
Aufrufe
2.517
Data2006
D
Zurück
Oben Unten