Android 主题样式

attrs.xml文件中声明属性名

比如Theme范围内定义的属性toastFrameBackground(Toast的背景)


    
    
    

theme.xml

  

    
    

Toast

        // 说明我们默认的Toast并没有直接使用这个"Theme.Toast",而是代码中动态设置一些属性,效果是一样的
        TN() {
            // XXX This should be changed to use a Dialog, with a Theme.Toast
            // defined that sets up the layout params appropriately.
            final WindowManager.LayoutParams params = mParams;
            params.height = WindowManager.LayoutParams.WRAP_CONTENT;
            params.width = WindowManager.LayoutParams.WRAP_CONTENT;
            params.format = PixelFormat.TRANSLUCENT;
            params.windowAnimations = com.android.internal.R.style.Animation_Toast;
            params.type = WindowManager.LayoutParams.TYPE_TOAST;
            params.setTitle("Toast");
            params.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                    | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
        }

实际中Toast用到的是在他的布局中用到的
transient_notification.xml



    


你可能感兴趣的:(Android 主题样式)