您的位置:首页 > 移动开发 > Android开发

eeyes总结

2015-08-31 22:13 393 查看
Action bar是一个标识应用程序和用户位置的窗口功能,并且给用户提供操作和导航模式。

Action bar的主要目的是:

        1.  提供一个用于识别应用程序的标示和用户的位置的专用空间。
        2.  在不同的应用程序之间提供一致的导航和视觉体验。
        3.  突出Activity的关键操作(如“搜索”、“创建”、“共享”等),并且在可预见的方法内给用户提供快捷的访问。

参考:http://blog.csdn.net/xyz_lmn/article/details/8132420

android kitkat 有一个新的特性可以设置手机状态栏的背景,让手机整个界面的风格保持一致,看起来非常清爽。

GitHub上有个项目可以实现从ActionBar的颜色渐变到边界的效果,项目地址:https://github.com/jgilfelt/SystemBarTint

import
com.readystatesoftware.systembartint.SystemBarTintManager;


SystemBarTintManager mTintManager = new SystemBarTintManager(this);

mTintManager.setStatusBarTintEnabled(true);

mTintManager.setNavigationBarTintEnabled(true);


mTintManager.setTintColor(getResources().getColor(R.color.primary_color));

With
the latest updates to the Android Support v7 AppCompat Library, revision 22.1, integrating Google’s Material Design has never been easier.AppCompatActivity.

上滑toolbar消失
https://github.com/ksoichiro/Android-ObservableScrollView
动画menu按钮
https://github.com/balysv/material-menu
抽屉菜单的摆放和布局通过
android:layout_gravity
属性来控制,可选值为left、right或start、end。通过xml来布局的话,需要把DrawerLayout作为父容器,组界面布局作为其第一个子节点,抽屉布局则紧随其后作为第二个子节点,这样就做就已经把内容展示区和抽屉菜单区独立开来,只需要分别非两个区域设置内容即可。

mDrawerLayout.openDrawer(Gravity.LEFT);

mDrawerLayout.setDrawerListener(new
DrawerLayout.DrawerListener() {

ViewPager中间的横线跟着屏幕的滑动而滑动
https://github.com/astuetz/PagerSlidingTabStrip
ViewPager

  1)ViewPager类直接继承了ViewGroup类,所有它是一个容器类,可以在其中添加其他的view类。

  2)ViewPager类需要一个PagerAdapter适配器类给它提供数据。

  3)ViewPager经常和Fragment一起使用,并且提供了专门的FragmentPagerAdapter和FragmentStatePagerAdapter类供Fragment中的ViewPager使用。

   在编写ViewPager的应用的使用,还需要使用两个组件类分别是PagerTitleStrip类和PagerTabStrip类,PagerTitleStrip类直接继承自ViewGroup类,而PagerTabStrip类继承PagerTitleStrip类,所以这两个类也是容器类。但是有一点需要注意,在定义XML的layout的时候,这两个类必须是ViewPager标签的子标签,不然会出错。

Android
ORMLite 框架
http://blog.csdn.net/lmj623565791/article/details/39121377
下拉刷新 https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh
synchronized
关键字,它包括两种用法:synchronized 方法和 synchronized 块。  

1.
synchronized 方法:通过在方法声明中加入 synchronized关键字来声明 synchronized 方法。这种机制确保了同一时刻对于每一个类实例,其所有声明为 synchronized 的成员函数中至多只有一个处于可执行状态,从而有效避免了类成员变量的访问冲突(只要所有可能访问类成员变量的方法均被声明为
synchronized)。synchronized 方法的缺陷:若将一个大的方法声明为synchronized 将会大大影响效率

2.
synchronized 块:通过 synchronized关键字来声明synchronized 块。语法如下:  
synchronized(syncObject) {  
//允许访问控制的代码  
}  
synchronized 块是这样一个代码块,其中的代码必须获得对象 syncObject (如前所述,可以是类实例或类)的锁方能执行

对synchronized(this)的一些理解 

Java语言的关键字,当它用来修饰一个方法或者一个代码块的时候,能够保证在同一时刻最多只有一个线程执行该段代码。

     一、当两个并发线程访问同一个对象object中的这个synchronized(this)同步代码块时,一个时间内只能有一个线程得到执行。另一个线程必须等待当前线程执行完这个代码块以后才能执行该代码块。

     二、然而,当一个线程访问object的一个synchronized(this)同步代码块时,另一个线程仍然可以访问该object中的非synchronized(this)同步代码块。

     三、尤其关键的是,当一个线程访问object的一个synchronized(this)同步代码块时,其他线程对object中所有其它synchronized(this)同步代码块的访问将被阻塞。

     四、当一个线程访问object的一个synchronized(this)同步代码块时,它就获得了这个object的对象锁。结果,其它线程对该object对象所有同步代码部分的访问都被暂时阻塞。

     五、以上规则对其它对象锁同样适用.

Android 已经提供DisplayMetircs 类可以很方便的获取分辨率。

DisplayMetrics display=
new DisplayMetrics();

getWindowManager().getDefaultDisplay().getMetrics(display);//将当前窗口的一些信息放在DisplayMetrics类中

在Toolbar上有一些默认的显示效果,注意:setNavigationIcon(),setOnMenuItemClickListener() 需要放在 setSupportActionBar之后才会生效



    private void moveToolbar(final float toTranslationY){

        if (mToolbar.getTranslationY() == toTranslationY){

            return;

        }

        final ValueAnimator animator = ValueAnimator.ofFloat(mToolbar.getTranslationY(), toTranslationY).setDuration(200);

        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override

            public void onAnimationUpdate(ValueAnimator animation) {

                float translationY = (Float) animator.getAnimatedValue();

                mToolbar.setTranslationY(translationY);

                mContent.setTranslationY(translationY);

                FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mContent.getLayoutParams();

                lp.height = (int) (getScreenHeight() - translationY - getStatusBarHeight() - lp.topMargin);

                mContent.requestLayout();

            }

        });

        animator.start();

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android