Android 在RelativeLayout中堆叠按钮
我想在Android中堆叠多个(圆形)按钮。这就是我想要实现的目标:Android 在RelativeLayout中堆叠按钮,android,android-layout,button,Android,Android Layout,Button,我想在Android中堆叠多个(圆形)按钮。这就是我想要实现的目标: 我试图在一个RelativeLayout中放置多个按钮(并将其位置设置为绝对位置),但这并没有达到我想要的结果,因为按钮在不同的密度/屏幕大小上没有正确的位置。有人有过这种按钮/布局的经验吗?我能做些什么来实现这个结果?在相对视图中创建,首先构建btn1,然后构建btn2,然后在另一个相对视图上构建btn3和btn4,最后构建btn 5,然后给出背景图像。你所要做的就是注意它们的尺寸 编辑: 这是我写的一段代码没有: <
我试图在一个RelativeLayout中放置多个按钮(并将其位置设置为绝对位置),但这并没有达到我想要的结果,因为按钮在不同的密度/屏幕大小上没有正确的位置。有人有过这种按钮/布局的经验吗?我能做些什么来实现这个结果?在相对视图中创建,首先构建btn1,然后构建btn2,然后在另一个相对视图上构建btn3和btn4,最后构建btn 5,然后给出背景图像。你所要做的就是注意它们的尺寸 编辑: 这是我写的一段代码没有:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<Button
android:id="@+id/btn1"
android:layout_width="250dp"
android:layout_height="180dp"
android:text="btn1" />
<Button
android:id="@+id/btn2"
android:layout_width="250dp"
android:layout_height="70dp"
android:layout_below="@+id/btn1"
android:text="btn2" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<Button
android:id="@+id/btn3"
android:layout_width="150dp"
android:layout_height="75dp"
android:text="btn3" />
<Button
android:id="@+id/btn4"
android:layout_width="150dp"
android:layout_height="75dp"
android:layout_below="@+id/btn3"
android:text="btn4" />
<Button
android:id="@+id/btn5"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:text="btn5" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
要创建这种类型的按钮
你必须将图像
切割成不同的大小,并将其放入布局中的图像按钮
中,使用起来非常简单。你可以创建这样的可绘制按钮,并在另一个按钮上放置一个按钮。你需要使用图像按钮我知道,但按钮仍然是可用的a squareOk,但当我这样做的时候,接触区也是圆的吗?试试吧,如果你给它们添加背景图像应该没问题。没问题,伙计:)如果它很好并且有效,你能接受它作为一个正确的答案吗?哈哈,当然可以!:)