Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 旋转图像视图';这是内线布局_Android_Android Layout - Fatal编程技术网

Android 旋转图像视图';这是内线布局

Android 旋转图像视图';这是内线布局,android,android-layout,Android,Android Layout,我正在开发一款Android卡游戏。 我想显示所有玩家的牌,所以我创建了4个线性布局。 1为顶级玩家、左侧玩家、右侧玩家和底部玩家 我试着用同样的图像来画牌,因此我试着旋转边路球员(左和右球员)的牌 出于某种原因,最上面和最下面的玩家卡看起来不错,但是旁边的玩家卡太小了 这是我的左播放器布局: <LinearLayout android:id="@+id/leftParentLayout" android:layout_width="80dp"

我正在开发一款Android卡游戏。 我想显示所有玩家的牌,所以我创建了4个线性布局。 1为顶级玩家、左侧玩家、右侧玩家和底部玩家

我试着用同样的图像来画牌,因此我试着旋转边路球员(左和右球员)的牌

出于某种原因,最上面和最下面的玩家卡看起来不错,但是旁边的玩家卡太小了

这是我的左播放器布局:

 <LinearLayout
        android:id="@+id/leftParentLayout"
        android:layout_width="80dp"
        android:layout_height="200dp"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.026"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.381">

        <ImageView
            android:id="@+id/player_left_card_3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_weight="1"
            android:clickable="false"
            android:paddingBottom="1dp"
            android:paddingEnd="1dp"
            android:paddingLeft="1dp"
            android:paddingRight="1dp"
            android:rotation="90" />

        <ImageView
            android:id="@+id/player_left_card_5"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_weight="1"
            android:clickable="false"
            android:paddingBottom="1dp"
            android:paddingEnd="1dp"
            android:paddingLeft="1dp"
            android:paddingRight="1dp"
            android:rotation="90" />

        <ImageView
            android:id="@+id/player_left_card_1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_weight="1"
            android:clickable="false"
            android:paddingBottom="1dp"
            android:paddingEnd="1dp"
            android:paddingLeft="1dp"
            android:paddingRight="1dp"
            android:rotation="90" />

        <ImageView
            android:id="@+id/player_left_card_2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_weight="1"
            android:clickable="false"
            android:paddingBottom="1dp"
            android:paddingEnd="1dp"
            android:paddingLeft="1dp"
            android:paddingRight="1dp"
            android:rotation="90" />

        <ImageView
            android:id="@+id/player_left_card_4"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_weight="1"
            android:clickable="false"
            android:paddingBottom="1dp"
            android:paddingEnd="1dp"
            android:paddingLeft="1dp"
            android:paddingRight="1dp"
            android:rotation="90" />

    </LinearLayout>

虽然高度应为200,宽度应为80,但卡片较小。 我怀疑是在轮换之前计算了牌的大小,然后轮换以某种方式缩小了它们,看起来左边玩家的牌宽与最上面的玩家的牌宽相同,但由于轮换,它应该更大

如何旋转卡片,但保持其原始大小? 谢谢

这是游戏的截图

我怀疑卡片大小是在旋转之前计算的,然后旋转会以某种方式缩小它们

我认为这可能是错误的。Android计算最终的宽度和高度测量值,并在布局中进行调整。因为它关注最终显示的内容,并且它引用了您提到的属性

对于
ImageView
中的独立卡,尝试以宽度或高度或两者兼有的方式提供
wrap\u内容-

android:layout_width="wrap_content"
android:layout_height="wrap_content"

另请注意
200dp
应容纳所有5张卡的宽度加上您拥有的填充(
2dp
每张卡)。而
80dp
宽度应与卡的高度加上
2dp
填充相适应。对于
线性布局

您好,谢谢您的回复!我试过你说的话,但似乎没有改变任何事情尝试
android:layout\u width=“wrap\u content”android:layout\u height=“wrap\u content”
对于
LinearLayout
可能是什么?