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

标签 android android-layout

我是 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/

相关文章:

Android:在 View Canvas 上绘图不起作用

android - getPositionForSection 和 getSectionForPosition 的区别

安卓服务

android - 多个根标签错误Android

android - 无法将页脚添加到 ScrollView - android

java - 关闭抽屉导航箭头动画

安卓/ Kotlin : How to get a DocumentReference to a document in a sub-collection in Firestore?

android - 在 Android 中以编程方式实现 splitView

android - 在另一个布局中扩充一个布局

android-layout - 如何创建 Android Google Play 的 GridView ,如动态加载不同尺寸图像的小部件