[英]Android game: remove padding either side of screen
我是Android的新手,正在开发一款非常基本的游戏。 我想知道如何删除游戏主屏幕两侧的填充物,这样游戏将占据正在使用的任何设备的整个屏幕。
我最初认为它与dimens.xml文件有关:
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
我尝试将它们都更改为0dp,但是白色填充仍保留在屏幕上。 另外-在activity_play_game.xml中,我具有以下内容:
android:layout_width="match_parent"
android:layout_height="match_parent"
我想这可能与它有关吗? 有人知道我要去哪里错吗? 非常感谢!
将此添加为您的Activit布局。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
</RelativeLayout>
您应该看到整个屏幕充满黑色。 然后尝试将其添加到内部
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:text="Margin Padding Test" />
并尝试将android:padding="20dp"
和android:layout_margin="20dp"
到RelativeLayout和TextView中。 当您尝试这些属性的不同组合时,您应该能够将布局更新为所需的外观。
边距更改布局在其父级中的放置方式。
填充更改布局在其内部的放置方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.