用两个按钮绘制矩形
Drawing rectangle shape with two buttons
我正在尝试绘制这个形状,包括 2 个按钮,一个用于患者,另一个用于医生,我该如何做这样的事情?
好吧,有很多方法可以做到这一点,我使用 shape
做到了,这是输出
您必须创建一个 oval_left.xml
和 oval_right.xml
,然后创建两个 Buttons
并将这些 backgrounds
应用于它们。
这是oval_left.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="40dp">
<solid android:color="@color/colorPrimary"/>
<corners
android:bottomRightRadius="0dp"
android:bottomLeftRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="0dp"/>
</shape>
这是 oval_right.xml
相同但更改了值和颜色
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="40dp">
<solid android:color="@android:color/white"/>
<corners
android:bottomRightRadius="20dp"
android:bottomLeftRadius="0dp"
android:topLeftRadius="0dp"
android:topRightRadius="20dp"/>
</shape>
希望这就是您要找的。
此外,如果您想查看完整代码,请查看此存储库:shapeovalandrectangleview
我正在尝试绘制这个形状,包括 2 个按钮,一个用于患者,另一个用于医生,我该如何做这样的事情?
好吧,有很多方法可以做到这一点,我使用 shape
做到了,这是输出
您必须创建一个 oval_left.xml
和 oval_right.xml
,然后创建两个 Buttons
并将这些 backgrounds
应用于它们。
这是oval_left.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="40dp">
<solid android:color="@color/colorPrimary"/>
<corners
android:bottomRightRadius="0dp"
android:bottomLeftRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="0dp"/>
</shape>
这是 oval_right.xml
相同但更改了值和颜色
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="40dp">
<solid android:color="@android:color/white"/>
<corners
android:bottomRightRadius="20dp"
android:bottomLeftRadius="0dp"
android:topLeftRadius="0dp"
android:topRightRadius="20dp"/>
</shape>
希望这就是您要找的。
此外,如果您想查看完整代码,请查看此存储库:shapeovalandrectangleview