java - 图像未填满正方形
问题描述
我希望图像填满所有框,我不想在它们之间有那些边框。图像没有填满所有的方框。我尝试了一切,但没有任何效果。如果有人可以帮助我,我将非常感激,问题是当我将它旋转 90 度时。
Photo1 这就是它的 样子 Photo2 这就是我想要的样子
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/tile2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<ImageView
android:id="@+id/tile_player_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="@+id/tile_enemy_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</RelativeLayout>
</LinearLayout>
这是java
tiles[2].setImageResource(getResources().getIdentifier("tile_lava", "drawable", getPackageName()));
tiles[0].setRotation(90);
当我旋转它时,我会在它们之间收到空格
解决方案
尝试将以下内容添加到layout.xml中不适合磁贴的 Imageviews。
android:scaleType="fitXY"
编辑
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3">
<ImageView
android:id="@+id/tile2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:layout_weight="1" />
<ImageView
android:id="@+id/tile_player_2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:layout_weight="1" />
<ImageView
android:id="@+id/tile_enemy_2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:layout_weight="1" />
</LinearLayout>
推荐阅读
- python - 如何删除作为 Python 列表元素的字符串的一些前导字符?
- python-3.8 - psutil.STATUS_DEAD 状态是否与 psutil.STATUS_ZOMBIE 相同?
- php - 删除wordpress中的第一行html源代码
- stripe-payments - 没有这样的令牌:'btok_1JGm2oKFR93cFUSYN2bui4Yb' 当我尝试为 Stripe 客户创建银行账户时
- javascript - 无法使用官方示例在 Slate.js 编辑器中清楚地删除链接
- sql - Laravel query where field is less than sum of another field in related table (polymorphic relationship)
- algorithm - 找到强连通图,使得最大和最小边之间的差异最小
- javascript - 画布上方的三个 js 和 react 按钮
- c# - 无法获取多对多表属性的数据
- python - 当内核停止运行时触发类似“重新启动并运行所有”的行为