简体   繁体   English

Android弧形按钮布局

[英]Android Curved Button Layout

I want to make the following curved button layout in android, I just want to know if it is feasible with Android Layouts. 我想在android中制作以下弧形按钮布局,我只想知道是否可以在Android Layouts中使用。 If yes can anyone please help me how to work for these layouts. 如果是,谁能帮助我如何处理这些布局。

Screenshot Attached 附屏幕截图

Here Circle is a Button C, Left hand side complete part is Button A, and the Right Hand side Complete Part is Button B. 这里的圆是按钮C,左侧的完整部分是按钮A,右侧的完整部分是按钮B。

I want to use the click events on all the three and the layout should look same as the image is attached 我想对所有三个都使用click事件,并且布局应与附加图像的外观相同

Here I just seriously want to say that, I have 3 images with me.. whole left purple part is button A (not only the rectangular one), and whole right purple parth is button B (not only the rectangular one). 在这里我只想认真地说一遍,我有3张图像。.整个紫色左部分是按钮A(不仅是矩形的),整个紫色右部分是按钮B(不仅是矩形的)。 and the circle is in between both the buttons as shown in the layout. 圆圈位于两个按钮之间,如布局所示。 Now please help me.I have to make same layout. 现在请帮助我。我必须进行相同的布局。 and I have left and right purple image and circle image too 而且我也有左右紫色图像和圆形图像

Please help 请帮忙

在此处输入图片说明

Use this, Create this XML inside your drawable folder and name it as mybutton.xml 使用此方法,在可绘制文件夹中创建此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>

and then just add this to your button like, 然后将其添加到您的按钮中

android:background="@drawable/mybutton"

you can change color of button's and other parameter as per your requirement. 您可以根据需要更改按钮和其他参数的颜色。

EDIT 编辑

You have to use RelativeLayout to achieve this as Circle is above ButtonA and ButtonB 您必须使用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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM