我想在android中制作以下弯曲按钮布局,我只想知道Android Layouts是否可行。如果是的话,请任何人帮助我如何为这些布局工作。
截图附件
此处圆圈是按钮C,左手边完整部分是按钮A,右手边完整部分是按钮B。
我想在所有三个上使用点击事件,布局应该与附加图像相同
这里我只是非常想说,我有3张图片。整个左紫色部分是按钮A(不仅是矩形的),而整个右紫色部分是按钮B(不仅是矩形的) 。并且圆圈位于两个按钮之间,如布局中所示。现在请帮助我。我必须做同样的布局。我也有左右紫色图像和圆形图像
请帮忙
答案 0 :(得分:1)
使用此选项,在drawable文件夹中创建此XML并将其命名为mybutton.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<!-- you can use any color you want I used here gray color-->
<solid android:color="#ABABAB"/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>
然后将其添加到您的按钮,例如
android:background="@drawable/mybutton"
您可以根据需要更改按钮和其他参数的颜色。
修改强>
你需要使用RelativeLayout来实现这一点,因为Circle高于ButtonA和ButtonB
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/btn_circle"
android:layout_height="wrap_content"
android:layout_width="100dip"
android:layout_marginBottom="20dip"
android:layout_centerHorizontal="true"
/>
<Button /* Button A, Align to parent left and bottom */ />
<Button /* Button B, Align to parent Right and bottom */ />
</RelativeLayout>