美文网首页
Android开发总结(九)

Android开发总结(九)

作者: 程序猿男神 | 来源:发表于2018-05-11 09:58 被阅读25次

    文/程序员男神

    前言

    新年开篇,来篇简单的知识总结,后续会持续更新。

    一、状态栏、标题栏、导航栏的区别
    状态栏:是指手机左上最顶上,显示中国移动、安全卫士、电量、网速等等,在手机的顶部。下拉就会出现通知栏。

    标题栏:是指一个APP程序最上部的titleBar,从名字就知道它显然就是一个应用程序一个页面的标题了,例如打开QQ消息主页,最上面显示消息那一栏就是标题栏。

    导航栏:是手机最下面的返回,HOME,主页三个键,有些是一个按钮。

    二、Android抽象布局——include、merge 、ViewStub
    在布局优化中,Android的官方提到了这三种布局<include />、<merge />、<ViewStub />,并介绍了这三种布局各有的优势,,下面也是简单说一下他们的优势,以及怎么使用。
    参考文档:http://blog.csdn.net/xyz_lmn/article/details/14524567

    三、问题:ViewPager会对其中的Fragment进行预加载。也就是说用户第一次打开第一个界面的时候,不仅第一个界面会进行加载,其他的界面也会进行界面的预加载。
    参考文档:https://blog.csdn.net/njp_njp/article/details/80003406

    四、问题:RadioGroup里面有两个RadioButton怎么设置默认值?
    第一个RadioButton设置 android:checked="true" 属性后,两个RadioButton就不互斥了。其实,这个问题的解决方式很简单,给你的两个RadioButton 添加 Id 就可以了。

      <RadioGroup
            android:id="@+id/radio_groups"
            android:layout_width="match_parent"
            android:layout_height="44dp"
            android:orientation="horizontal">
    
            <RadioButton
                android:id="@+id/rb1"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginLeft="@dimen/dimen_1"
                android:layout_weight="1"
                android:background="@color/white"
                android:button="@null"
                android:checked="true"
                android:gravity="center"
                android:text="未分配"
                android:textColor="@drawable/selector_radiogroup" />
    
            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginLeft="@dimen/dimen_1"
                android:layout_weight="1"
                android:background="@color/white"
                android:button="@null"
                android:gravity="center"
                android:text="已分配"
                android:textColor="@drawable/selector_radiogroup" />
        </RadioGroup>
    

    selector_radiogroup的radiobutton按钮的选中、不选中代码:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
           <item android:color="#0BC0BA" android:state_checked="true" />
           <item android:color="#A3A3A3" android:state_checked="false" />
    </selector>
    

    相关文章

      网友评论

          本文标题:Android开发总结(九)

          本文链接:https://www.haomeiwen.com/subject/jsqqfftx.html