gpt4 book ai didi

android - 创建显示工作日的切换按钮组

转载 作者:行者123 更新时间:2023-11-30 01:31:20 30 4
gpt4 key购买 nike

I want to create a toggle button exactly like this image below and display all toggle button in the same line to select weekdays for an alarm event.I have no idea regarding this.Please help.

enter image description here

最佳答案

这是我试过的广播组的例子。也许它对你有帮助。只看一次。

你的主要 xml 文件

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#655EF9"
android:orientation="horizontal">

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/radiobtn_bck"
android:button="@null"
android:checked="true"
android:gravity="center"
android:text="S" />

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@drawable/radiobtn_bck"
android:button="@null"
android:gravity="center"
android:text="M" />

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@drawable/radiobtn_bck"
android:gravity="center"
android:button="@null"
android:text="T" />

</LinearLayout>

这里是 drawable 文件夹中的 radiobtn_bck xml

<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/bg_shape" android:state_checked="true" />
<item android:drawable="@drawable/bg_shape" android:state_pressed="true" />
<item android:drawable="@drawable/bg_shape" android:state_focused="true" />
<item android:drawable="@drawable/bg_shape_purple" android:state_checked="false" />

bg_shape.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"

android:shape="oval">
<solid android:color="#ffffff" />
<size
android:width="40dp"
android:height="40dp" />

bg_shape_purple.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"

android:shape="oval">
<solid android:color="#655EF9" />
<size
android:width="40dp"
android:height="40dp" />

关于android - 创建显示工作日的切换按钮组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35720184/

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