gpt4 book ai didi

android - Android 中的分组水平按钮组

转载 作者:行者123 更新时间:2023-11-29 15:29:10 25 4
gpt4 key购买 nike

您好,我想知道是否有任何方法可以在 Android 中原生实现这种外观: http://jquerymobile.com/demos/1.0/docs/buttons/buttons-grouped.html

特别是我正在寻找具有圆形边缘的外部按钮,而内部按钮是完美的矩形。

最佳答案

你可以为每个制作Shape文件。只需为特定按钮创建定义角半径的形状文件并使用它。

例如顶部按钮 1

这样设置按钮背景

<Button android:id="@+id/btn1" android:text="Click" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="@drawable/mycorner"/>

在 drawable 文件夹中为不同的形状创建不同的 xml 文件,就像这里的 mycorner.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:bottomLeftRadius="8dip"
android:topRightRadius="8dip"
android:topLeftRadius="1dip"
android:bottomRightRadius="1dip"
/>
<padding android:left="5dp" android:right="5dp" android:top="5dp" android:bottom="5dp" />
<gradient android:startColor="#ffffff" android:endColor="#ffffff" />
</shape>

关于android - Android 中的分组水平按钮组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8726984/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com