gpt4 book ai didi

android - 在 Android 中创建自定义布局

转载 作者:行者123 更新时间:2023-11-29 21:58:14 25 4
gpt4 key购买 nike

我是 android 的新手,我想为我的弹跳球游戏使用以下布局(见下图)。请告诉我使用哪种布局。


enter image description here

最佳答案

我将使用 Vertical linearLayout 一分为二。

像这样:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="PlayingArea" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="horizontal" >
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="left_lower_box" />
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="right_lower_box" />
</LinearLayout>
</LinearLayout>

这只是一个示例;您可能不会为您的应用程序使用按钮,您需要设置高度和宽度。

关于android - 在 Android 中创建自定义布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12658895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com