创建Android应用程序一个三角形按钮角形、应用程序、按钮、Android

由网友(你是我病要我命)分享简介:我需要在我的Andr​​oid应用程序中创建安排这样的2个按钮:I need to create 2 buttons arranged like this in my android application:但问题是我创建的按钮是不是一个完美的黄金三角形状的按钮。事实上,它是一个方形按钮设置为背景图像。在这里,在这种...

我需要在我的Andr​​oid应用程序中创建安排这样的2个按钮:

I need to create 2 buttons arranged like this in my android application:

但问题是我创建的按钮是不是一个完美的黄金三角形状的按钮。事实上,它是一个方形按钮设置为背景图像。在这里,在这种情况下,有一个问题,即该图象附近的白色区域是可点击的并且我想的按钮更close.Which意味着在两个按钮之间的白色空间必须被消除,以最大。当我使用相对布局,问题是,当我点击1按钮,有时其他按钮也将被自动点击。这是因为一个按钮重叠的其他按钮。因此,没有重叠的按钮,我想这两个按钮是如此之近,他们会看起来像一个平行四边形actually.So我的问题是如何更改矩形按钮的形状为三角形按钮,这两个按钮可以安排在这样一种方式,它看起来像一平行四边形。任何人的帮助是很容易AP preciated?我没有从那里带开始知道了。因此,与编码部分一点点的帮助将很容易AP preciated..Thanks提前..

But the problem is that the button I have created is not a perfect traingle shaped button. In fact it is a square button with the image set as background. Here in this case there is a problem such that the white areas near the image is clickable and I want the buttons to be more close.Which means that the white space in between the two button has to be eliminated to maximum. When I use relative layout, the problem is that, when I click on 1 button, sometimes the other button also gets clicked automatically. This is because one button is overlapped to the other button. So without overlapping the buttons, I want these two buttons to be so close that they will look like a parallelogram actually.So my question is how do I change the shape of rectangle buttons to a triangular shaped button so that the two buttons can be arranged in such a way that it look like a parallelogram. Any help from anyone is easily appreciated?? I didn't know from where to start with. So a little help with the coding part would be easily appreciated..Thanks in advance..

推荐答案

就可以做到这一点使用形状:命名此箭头UP:

it is possible to do this using shape: name this arrow UP:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <rotate
            android:fromDegrees="45"
            android:toDegrees="45"
            android:pivotX="-40%"
            android:pivotY="87%" >
            <shape
                android:shape="rectangle" >
                <stroke android:color="@color/transparent" android:width="10dp"/>
                <solid
                    android:color="@color/your_color_here" />
            </shape>
        </rotate>
    </item>
</layer-list>

用法:

<Button
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:background="@drawable/arrow_up" />

对于其他三角形:

for the other triangle:

<Button
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:rotation="180"
    android:background="@drawable/arrow_up" />
阅读全文

相关推荐

最新文章