有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java制作按钮的最佳方法

我决定彻底改变我的应用程序,并制作了一个导航抽屉。我制作了所有的片段,但现在我需要在其中包含按钮。我以前从未在框架布局中放置过按钮,我想知道是否有更简单的方法。下面是奖励的片段。xml

    <FrameLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    xmlns:tools="http://schemas.安卓.com/tools"
    安卓:layout_width="match_parent"
    安卓:layout_height="match_parent"
    tools:context="east.myapplication.RewardsFragment">

    <!-- TODO: Update blank fragment layout -->

    </FrameLayout>

我想包括一些按钮,如

    <Button
    安卓:layout_width="match_parent"
    安卓:layout_height="wrap_content"
    安卓:text="Amazon"
    安卓:drawableLeft="@drawable/amazon"
    安卓:drawableStart="@drawable/amazon"
    安卓:layout_weight="0.07"
    tools:ignore="HardcodedText"
    安卓:textSize="35sp" />

    <Button
    tools:ignore="HardcodedText"
    安卓:layout_width="match_parent"
    安卓:layout_height="wrap_content"
    安卓:text="PlayStation"
    安卓:drawableLeft="@drawable/playstation"
    安卓:drawableStart="@drawable/playstation"
    安卓:layout_weight="0.07"
    安卓:textSize="35sp"/>

有没有人知道一种更简单的方法可以在我的fragment_奖励中包含所有这些按钮。不使用framelayout的xml?以前,当我在页面上放置按钮时,我使用的是LinearLayout


共 (1) 个答案

  1. # 1 楼答案

    我想出来了,你不需要框架布局,你可以像我过去那样使用线性布局