Designing day chooser like found in clock in android L

偶尔善良 提交于 2019-12-10 12:08:27

问题


I am working on an app where I want to put day chooser like below (which I saw in clock app of android L). Anyone knows how to achieve it? Or is there any library or project implementing this is present?


回答1:


Here is an example by radio group which i tried. maybe its helpful for you. just take a look once.

your main xml file

<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>

here radiobtn_bck xml in drawable folder

<?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" />



来源:https://stackoverflow.com/questions/33731543/designing-day-chooser-like-found-in-clock-in-android-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!