2012-12-23 52 views
3

我正在做一個有4名玩家的紙牌遊戲,其中手機所玩的3名玩家的紙牌的背面都在屏幕上,其中一部分在外面。我已經成功地爲頂部和左邊的玩家使用邊界進行了卡片視圖,但是在右側玩家出現問題時,爲卡片視圖設置左側邊距只會調整其大小並防止其離開屏幕。查看屏幕外的位置

這裏是截圖: Screenshot of the game

我想我在這裏失蹤的東西...

謝謝!

回答

4

我想你還需要設置右邊距,當試圖讓它離開屏幕右側。對於一個簡單的文本示例,如果您在屏幕上顯示「我在這裏」,並將左邊距設置爲-30dp,則會在屏幕中途退出。但是,如果將左邊距設置爲275dp,則會重新調整大小以保留在屏幕上,除非您還將右邊距設置爲100dp。爲了得到一張照片而不用調整大小,我必須將右邊距設置爲負值。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" > 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="275dp" 
    android:layout_marginRight="100dp" 
    android:text="here I am" /> 
<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/textView1" 
    android:layout_marginLeft="200dp" 
    android:layout_marginRight="-75dp" 
    android:src="@drawable/jack" /> 
</RelativeLayout> 
+0

非常感謝! 我嘗試設置邊緣togeather和它的作品,謝謝! – Androidz