2012-07-17 53 views
-4

我是新開發的android開發人員,經過幾年嚴格的C++編程,例如ogl,dx,sfml等apis,我真的對所有這些佈局和東西感到頭痛。如何使用Android SDK實現這種佈局?

基本上我問你如何實現以下設置:

enter image description here

我試過放在一起一些隨機的佈局和了所見即所得的編輯器修復它,但是這件事情只是催着我香蕉,我不能讓它起作用。感覺就像我所做的一樣,編輯的行爲有所不同。

如果有人可以給我一些提示,那就太棒了。

順便說一句,我可以創建一個事件形式[Activity在這種情況下]稱爲每個幀? [沒有遊戲循環吸!]

回答

0

我寧願向下打破一切成佈局彼此之內。這裏將是您需要的一個例子,但有很多方法可以定義完全相同的東西。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Large Text" 
     android:layout_marginTop="20dp" 
     android:layout_gravity="center" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="300dp" 
      android:layout_height="300dp" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:src="@drawable/icon" /> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Large Text" 
      android:layout_centerHorizontal="true" 
      android:layout_alignBottom="@+id/imageView1" 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 

    </RelativeLayout> 

    <ImageButton 
     android:id="@+id/imageButton1" 
     android:layout_width="200dp" 
     android:layout_height="50dp" 
     android:src="@drawable/icon" 
     android:layout_marginTop="50dp" 
     android:layout_gravity="center"/> 

</LinearLayout> 
+0

謝謝!在你的幫助下找出它。看起來我得手動鍵入邊距和大小,因爲他們的編輯器只是簡單地吹... ... BTW:愛這個社區減少我的線程<3 – user1255410 2012-07-17 19:56:57

+0

雅拖放的想法是偉大的,但實際使用非常令人沮喪。我通常會在屏幕上放下幾個項目,然後從代碼一側完全重做屏幕。線性佈局可能非常有限,但相對佈局會增加大量的定製。嘗試在佈局中輸入「android:」,然後讓它坐在一個分鐘和拇指的列表中,你可以看到所有相關佈局添加的可能性。如果你使用的是我不知道其他編輯器的eclipse。 – 2012-07-17 20:05:18