3

我正在与 4 名玩家一起玩纸牌游戏,其中手机播放的 3 名玩家的纸牌背面出现在屏幕上,其中一部分在外面。我已经成功地使用顶部和左侧玩家的卡片视图的边距来做到这一点,但是右侧的玩家有问题,设置卡片视图的左边距只是调整它的大小并防止它离开屏幕。

这是截图: 游戏截图

我想我在这里遗漏了一些东西......

谢谢!

4

1 回答 1

4

我认为你还需要在试图让它离开屏幕右侧时设置右边距。举一个简单的文本示例,如果屏幕上有“Here I Am”,并将左边距设置为 -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>
于 2012-12-23T15:03:31.717 回答