如何在Android中画出两个按钮之间的一条线? [英] How to draw a line between two buttons in android?

查看:191
本文介绍了如何在Android中画出两个按钮之间的一条线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的XML布局两个按钮为波纹管所示。

I have two buttons in my xml layout as shown bellow.

我用了一个活动单击此按钮。我想画这个按钮之间的线,如图所示。土特产品能帮我画这之间的界线用code或XML。

I used an activity for this button click. I want to draw a line between this buttons as shown. Could tou please help me to draw the line between this by using code or xml..

推荐答案

您可以使用自定义的视图中绘制如LineView线路和覆盖的onDraw

You can use an custom view to draw the line such as LineView and override the onDraw.

@Override
protected void onDraw(Canvas canvas)
{
    canvas.drawLine(0, 0, getWidth(), getHeight(), m_paint);
}

然后使用XML来实现你想要的布局。

Then use the XML to achieve the layout you want.

<com.android.drawable.LineView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/leftButton"
    android:layout_toLeftOf="@id/rightButton"
    android:layout_below="@id/leftButton"
    android:layout_above="@id/rightButton"
    />

这篇关于如何在Android中画出两个按钮之间的一条线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆