xianzhez notes


  • Home

  • Categories

  • Archives

  • Tags

Fragment生命周期与重建

Posted on 2016-07-02   |   In Android Tips

Fragment生命周期与重建

Activity lifecycle and Fragment lifecycle

FragementManager fm = activity.getFragmentManager();

activity -> fragmentController -> fragmentManager -> fragment

Read more »

Web Tips

Posted on 2016-06-17   |   In Web

Tips

#flex-box

##Properties for the Parent(flex container)

####1. display
This defines a flex container; inline or block depending on the given value. It enables a flex context for all its direct children.

1
2
3
.container {
display: flex; /* or inline-flex */
}

####2. flex-direction
This establishes the main-axis, thus defining the direction flex items are placed in the flex container. Flexbox is (aside from optional wrapping) a single-direction layout concept. Think of flex items as primarily laying out either in horizontal rows or vertical columns.

1
2
3
.container {
flex-direction: row | row-reverse | column | column-reverse;
}
Read more »

SASS & SCSS

Posted on 2016-05-28   |   In Web

SASS & SCSS

###Variables
We can declare variables in our file that we can reuse throughout our document. This is common for colours and font stacks, and is probably one of the most handy uses of variables off the bat. Here’s the SCSS:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$pad : 2em;
$color-primary : rgb(40,40,40);
$color-secondary : rgb(40,170,220);
body {
background-color: $color-primary;
}
h1 {
color: $color-secondary;
}
.container {
padding: $pad;
}

And here’s the compiled CSS:

1
2
3
4
5
6
7
8
9
10
11
body {
background-color: #282828;
}
h1 {
color: #28aadc;
}
.container {
padding: 2em;
}
Read more »

CSS Basics

Posted on 2016-05-23   |   In Web

#Introduction to CSS

#How CSS works
>

####What is CSS?
CSS is a language for specifying how documents are presented to users — how they are styled, laid out, etc.

####How does CSS affect HTML?
A CSS rule is formed from:

  • A set of properties, which have values set to update how the HTML content is displayed, for example I want my element's width to be 50% of its parent element, and its background to be red.
  • A selector, which selects the element(s) you want to apply the updated property values to. For example, I want to apply my CSS rule to all the paragraphs in my HTML document.

####A quick CSS example
a stylesheet is applied to the HTML using a element

Read more »

CSS Layout

Posted on 2016-05-18   |   In Web

#CSS layout

#Introduction to CSS Layout

###The flow
Each elements in the document alters the flow of text in various ways:

  • Some elements can simply follow the text flow as if they were non-existent.
  • Some elements can force a line break at any point in the flow whether it has reached the edge of the document or not.
  • Some elements can create a new text flow for their inner content independent from the main text flow.

####Elements display categories

The element behavior is defined using the property display. This property can take tons of values but let's focus on the four most important:

  • none
    This value completely removes the element from the flow, exactly as if the element and its content weren't there in the first place.
  • inline
    This value makes an element "transparent": it flows with the text normally and its content is part of the global text flow.
  • block
    This value is for the element to break the text flow with a forced line break before and after it. Its content is no longer part of the global text flow and flows only within the constraints provided by the element box model.
  • inline-block
    This value makes the element somewhat in between inline and block type display: like inline boxes it flows with the text normally but, like block boxes, it's content is no longer part of the global text.
Read more »

HTML Basics

Posted on 2016-05-15   |   In Web

#HTML

#Introduction

####markup

markup: a language with specific syntax that instructs a Web browser how to display a page

###Element
Some tags are self-closing and do not contain any content.

###Tags

###Attributes

Attributes usually consist of 2 parts:

  • An attribute name
  • An attribute value

A few attributes can only have one value. They are Boolean attributes and may be shortened by only specifying the attribute name or leaving the attribute value empty. Thus, the following 3 examples have the same meaning:

1
2
3
4
5
<input required="required">
<input required="">
<input required>

###Named character references
Four common named character references:

  • > denotes the greater-than sign (>)
  • < denotes the less-than sign (<)
  • & denotes the ampersand (&)
  • " denotes double quote (")
Read more »

Style CSS

Posted on 2016-05-10   |   In Web

#Style CSS

#Style text

##Fundamental text and font styling
Two categories:

  • Font styles: Properties that affect the font that is applied to the text, affecting what font is applied, how big it is, whether it is bold, italic, etc.
  • Text layout styles: Properties that affect the spacing and other layout features of the text, allowing manipulation of for example the space between lines and letters, and how the text is aligned within the content box.

###Fonts

####Color
The color property sets the color of the foreground content of the selected elements (which is usually the text, but can also include a couple of other things, such as an underline or overline placed on text using the text-decoration property).

1
2
3
p {
color: red;
}
Read more »

JavaSrcipt Garden

Posted on 2016-05-07   |   In Web

#Objects

###Object Usage and Properties
Everything in JavaScript acts like an object, with the only two exceptions being null and undefined.

####Accessing Properties

The properties of an object can be accessed in two ways, via either the dot notation or the square bracket notation.

1
2
3
4
5
6
7
8
9
var foo = {name: 'kitten'}
foo.name; // kitten
foo['name']; // kitten
var get = 'name';
foo[get]; // kitten
foo.1234; // SyntaxError
foo['1234']; // works

The notations work almost identically, with the only difference being that the square bracket notation allows for dynamic setting of properties and the use of property names that would otherwise lead to a syntax error.

Read more »

Professional JavaScript for Web Developers

Posted on 2016-05-03   |   In Web

#JavaScript

#1. JavaScript简介

###1.2 JavaScript实现
JavaScript的实现包括了三部分:

  • 核心(ECMAScript)
  • 文档对象模型(DOM)
  • 浏览器对象模型(BOM)

#2. 在HTML中使用JavaScript

###2.1 <script>元素
HTML4.01中<script>的6个属性:

  • async:可选。表示应该立即下载脚本,但不应妨碍页面中的其他操作,比如下载其他资源或等待加载其他脚本。只对外部脚本文件有效。

  • charset:可选。表示通过src属性指定的代码的字符集。由于大多数浏览器户忽略它的值,因此这个属性很少有人用。

  • defer: 可选。表示脚本可以延迟到文档完全被解析和显示之后再执行。只对外部脚本文件有效。IE7及更早版本对嵌入脚本也支持这个属性。

  • language:已废弃。原来用于表示编写代码使用的脚本语言(如JavaScript、JavaScript1.2或者VBScript)。大多数浏览器会忽略这个属性,因此也没有必要再使用了。

  • src:可选。表示包含要执行代码的外部文件。

    Read more »

Senior Android Development

Posted on 2016-04-02   |   In Android

App研发录

#1.重构

1.1重新规划Android项目结构

将业务与逻辑分离,建立包结构。

###1.4 实体化编程

#####1.4.1使用fastJSON或GSON
坑:代码混淆时带来的混乱

  1. 加了符号Annotation的实体属性,一使用就崩溃。
  2. 当有泛型属性时,一使用就崩溃。
1
2
-keepattributes Signature //避免混淆泛型
-keepattributes *Annotation* //不混淆注释

###1.5 Adapter模板

使用ViewHolder机制

Read more »
123
xianzhez

xianzhez

25 posts
9 categories
14 tags
© 2017 xianzhez
Powered by Hexo
Theme - NexT.Muse