• Radiobutton也来做tab标签


    Android进阶之UI深度定制系列(二)

                                              Radiobutton也来做tab标签

    效果图:

    XML布局:

    <RadioGroup
            android:id="@+id/radioGroup1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
    
            <RadioButton
                android:id="@+id/radio0"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/XXX"
                android:button="@drawable/none"
                android:checked="true"
                android:drawableTop="@drawable/yyy"
                android:text="RadioButton" />
    
            <RadioButton
                android:id="@+id/radio1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/xxx"
                android:button="@drawable/none"
                android:drawableTop="@drawable/yyy"
                android:text="RadioButton" /> 
    
            <RadioButton
                android:id="@+id/radio2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/xxx"
                android:button="@drawable/none"
                android:drawableTop="@drawable/yyy"
                android:text="RadioButton" />
    
        </RadioGroup>

    重要属性:

    android:drawableTop,android:button,android:background

    随着ADT不断升级,可视化的UI编辑变得更加方便高效,通过Properties面板,能够快捷的查询设置UI组件各种属性,
    理解RadioButton是实现个性化定制前提,android:drawableTop表示组件内相对上方的图片资源,默认是没有的;android:button表示我们平时看到的圆圈Radio,是一个drawable资源而不是按钮id;android:background当然表示整个RadioBtton的背景图片。
    为了时三个RadioButton能够均匀占据屏幕的宽,设置layout_width为match_parent,同时设置他们的layout_weight为一,即在分配宽度时得到相同的优先级。
    优势:
    保持选中状态,实现不同视觉效果,而通常的做法只能在单击或触摸时有效果的变化,而本例将实现这种效果的固化,就是利用了RadioButton的checked属性

    作者:小文字
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
  • 相关阅读:
    提高软件开发内功的推荐阅读列表
    oracle如何使用dblink链接另一个数据库
    代码不可读
    oracle如何使用dblink链接另一个数据库
    程序猿的吐槽三——改进还是不改进
    程序猿的吐槽一
    软件模式
    用户分类
    Matplotlib简介和pyplot的简单使用——subplot
    Linux下Eclipse的PyDev和CDT的安装和配置
  • 原文地址:https://www.cnblogs.com/avenwu/p/2592820.html
Copyright © 2020-2023  润新知