2011-07-30 53 views
0

這是我的佈局文件是::佈局問題,提高

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout android:id="@+id/relativeLayout1" 
    android:layout_width="wrap_content" android:layout_height="wrap_content" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:background="@drawable/bg1" 
> 
<!-- <RelativeLayout android:id="@+id/relativeLayo" 
    android:layout_width="480dp" android:layout_height="320dp" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_marginLeft="20dp" 
    android:background="@drawable/bg1"> --> 



     <ImageView android:src="@drawable/lets_play" 
      android:layout_width="wrap_content" android:layout_marginLeft="260dp" 
      android:id="@+id/imageView1" android:layout_height="wrap_content" 
      android:layout_marginTop="40dp" 

      ></ImageView> 


    <ImageView android:src="@drawable/show_me" 
      android:layout_width="wrap_content" android:layout_marginLeft="220dp" 
      android:id="@+id/imageView1" android:layout_height="wrap_content" 
      android:layout_marginTop="60dp" 

      ></ImageView> 

     <ImageButton android:id="@+id/anim_btn_play" 
      android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:layout_marginLeft="260dp" android:layout_marginTop="150dp" 
      android:src="@drawable/play"> 
     </ImageButton> 
</RelativeLayout> 

和移動輸出類似::

![這裏] [1]

現在我問題是::我想設置480 * 320大小的屏幕,佈局從左側開始。在右側有黑色部分殘留。我有大約10個活動,所有活動都將顯示相同的方向。現在我想在像:: 中心顯示![這] [2]

所以你能告訴我的解決方案?

回答

1

最簡單的方法是用別的東西來包裝你的相對佈局,大概線性佈局就可以了,然後:

<linearlayout gravity=center> 
    <relativelayout width=480dp height=320dp> 
    ... 

應該速戰速決特別小480x320的屏幕上你的問題。

但是,我建議你重新考慮一下你的背景圖片,以便可以採用不同長寬比的屏幕,考慮尋找nine-patch,並讓背景「可以拖拽」或製作一個自定義的可拖拽,它將停留在屏幕中間。

+0

<相對佈局也給重力,所以我可以做到這一點相對? –