Skip to content

Commit 0fc9cd5

Browse files
committed
update version 1.0.2
1 parent 177a2e0 commit 0fc9cd5

File tree

4 files changed

+184
-51
lines changed

4 files changed

+184
-51
lines changed

README-CH.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Android-ScaleLayout
2+
3+
一个简单的,方便的多屏适配的Android库
4+
5+
## 本质就是百分比缩放
6+
7+
### 和 android-percent-support-lib 的不同
8+
9+
1. **更科学**
10+
``android-percent-support-lib`` 是父控件和子控件的百分比关系
11+
``Android-ScaleLayout`` 是设计界面和设备界面的百分比关系
12+
13+
2. **更方便**
14+
``android-percent-support-lib`` 需要把设计尺寸算成百分比
15+
``Android-ScaleLayout`` 直接把设计尺寸填入``layou.xml``即可
16+
17+
18+
## How to look?
19+
20+
![screenhot](/screenhot.png)
21+
22+
23+
## 原理
24+
25+
```java
26+
float realPixel = percent * designPixel
27+
```
28+
29+
### Pix Mode
30+
31+
```java
32+
float realPixel = percent * designPixel
33+
34+
float percent = mScreenWidth / designScreenWidth
35+
36+
float designPixel = res.getDimensionPixelSize()
37+
```
38+
```java
39+
float realPixel = mScreenWidth * res.getDimensionPixelSize() / designScreenWidth
40+
```
41+
42+
### DP Mode
43+
```java
44+
float realPixel = percent * designPixel
45+
46+
float percent = mScreenWidth / designScreenWidth
47+
float designPixel = designDP * designDensity // dp to pixel
48+
49+
float designDP = res.getDimensionPixelSize() / mDensity
50+
```
51+
```java
52+
float realPixel = (mScreenWidth * designDensity * getPixelSize()) / (designScreenWidth * mDensity)
53+
```
54+
55+
## 使用
56+
57+
### 0. 依赖
58+
59+
```
60+
dependencies {
61+
compile 'cn.gavinliu.android.lib:ScaleLayout:1.0.2'
62+
}
63+
```
64+
65+
### 1. 初始化
66+
67+
```java
68+
public class MyApplication extends Application {
69+
70+
@Override
71+
public void onCreate() {
72+
ScaleConfig.create(this,
73+
1080, // Design Width
74+
1920, // Design Height
75+
3, // Design Density
76+
ScaleConfig.DIMENS_UNIT_DP);
77+
}
78+
}
79+
```
80+
81+
### 2. Scale***Layout
82+
83+
只需要把 ``FrameLayout`` ``LinearLayout`` ``RelativeLayout`` 替换成 ``ScaleFrameLayout`` ``ScaleLinearLayout`` ``ScaleRelativeLayout``.
84+
85+
### 3. Scale by width or height
86+
87+
```xml
88+
<attr name="layout_scale_by" format="enum">
89+
<enum name="width" value="0"/>
90+
<enum name="height" value="1"/>
91+
</attr>
92+
```
93+
```xml
94+
app:layout_scale_by="width"
95+
```
96+
97+
### 支持的属性
98+
99+
```xml
100+
<attr name="android:layout_width"/>
101+
<attr name="android:layout_height"/>
102+
103+
<attr name="android:layout_margin"/>
104+
<attr name="android:layout_marginLeft"/>
105+
<attr name="android:layout_marginTop"/>
106+
<attr name="android:layout_marginRight"/>
107+
<attr name="android:layout_marginBottom"/>
108+
<attr name="android:layout_marginStart"/>
109+
<attr name="android:layout_marginEnd"/>
110+
111+
<attr name="android:padding"/>
112+
<attr name="android:paddingLeft"/>
113+
<attr name="android:paddingTop"/>
114+
<attr name="android:paddingRight"/>
115+
<attr name="android:paddingBottom"/>
116+
<attr name="android:paddingStart"/>
117+
<attr name="android:paddingEnd"/>
118+
```
119+
120+
## License
121+
122+
MIT

README.md

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,32 @@
11
# Android-ScaleLayout
22

3-
一个简单的,方便的多屏适配的Android库
3+
A Simple & Convenience MultiScreen-Support-Library for Android
44

5-
## 本质就是百分比缩放
5+
## The essence is percent scaling.
66

7-
### android-percent-support-lib 的不同
7+
### different from ``android-percent-support-lib``
88

9-
1. **更科学**
10-
``android-percent-support-lib`` 是父控件和子控件的百分比关系
11-
``Android-ScaleLayout`` 是设计界面和设备界面的百分比关系
9+
1. **More reliable**
10+
``android-percent-support-lib`` The percentage of the parent and child views.
11+
``Android-ScaleLayout`` The percentage of the design and devices screens.
1212

13-
2. **更可靠**
14-
``android-percent-support-lib`` 可能会导致大量尺寸的精度丢失
15-
``Android-ScaleLayout`` 精度最多丢失1px
16-
17-
3. **更方便**
18-
``android-percent-support-lib`` 需要把设计尺寸算成百分比
19-
``Android-ScaleLayout`` 直接把设计尺寸填入``layou.xml``即可
13+
2. **More convenience**
14+
``android-percent-support-lib`` need to calculate percent
15+
``Android-ScaleLayout`` directly write the design size on ''layout.xml``
2016

2117

2218
## How to look?
2319

2420
![screenhot](/screenhot.png)
2521

2622

27-
## 基本原理
28-
29-
+ 设计属性
30-
设计手机的宽高,像素密度,设计尺寸
31-
+ 设备属性
32-
设备手机的宽高,像素密度
23+
## Principle
3324

3425
```java
3526
float realPixel = percent * designPixel
3627
```
3728

38-
### Pix 模式
29+
### Pix Mode
3930

4031
```java
4132
float realPixel = percent * designPixel
@@ -48,22 +39,62 @@ float designPixel = res.getDimensionPixelSize()
4839
float realPixel = mScreenWidth * res.getDimensionPixelSize() / designScreenWidth
4940
```
5041

51-
### DP 模式
42+
### DP Mode
5243
```java
5344
float realPixel = percent * designPixel
5445

55-
float percent = mScreenWidth / designScreenWidth // 屏幕比
56-
float designPixel = designDP * designDensity // dp pixel
46+
float percent = mScreenWidth / designScreenWidth
47+
float designPixel = designDP * designDensity // dp to pixel
5748

58-
float designDP = res.getDimensionPixelSize() / mDensity // DesignDP是写入在xml文件中的,需要通过 pix/density 还原出来
49+
float designDP = res.getDimensionPixelSize() / mDensity
5950
```
6051
```java
6152
float realPixel = (mScreenWidth * designDensity * getPixelSize()) / (designScreenWidth * mDensity)
6253
```
6354

64-
## 如何使用
55+
## Usage
56+
57+
### 0. dependencies
58+
59+
```
60+
dependencies {
61+
compile 'cn.gavinliu.android.lib:ScaleLayout:1.0.2'
62+
}
63+
```
64+
65+
### 1. Initialize
66+
67+
```java
68+
public class MyApplication extends Application {
69+
70+
@Override
71+
public void onCreate() {
72+
ScaleConfig.create(this,
73+
1080, // Design Width
74+
1920, // Design Height
75+
3, // Design Density
76+
ScaleConfig.DIMENS_UNIT_DP);
77+
}
78+
}
79+
```
6580

66-
### 支持的属性
81+
### 2. Scale***Layout
82+
83+
Only need to replace ``FrameLayout`` ``LinearLayout`` ``RelativeLayout`` to ``ScaleFrameLayout`` ``ScaleLinearLayout`` ``ScaleRelativeLayout``.
84+
85+
### 3. Scale by width or height
86+
87+
```xml
88+
<attr name="layout_scale_by" format="enum">
89+
<enum name="width" value="0"/>
90+
<enum name="height" value="1"/>
91+
</attr>
92+
```
93+
```xml
94+
app:layout_scale_by="width"
95+
```
96+
97+
### Support Attrs
6798

6899
```xml
69100
<attr name="android:layout_width"/>
@@ -86,26 +117,6 @@ float realPixel = (mScreenWidth * designDensity * getPixelSize()) / (designScree
86117
<attr name="android:paddingEnd"/>
87118
```
88119

89-
### 初始化
90-
91-
```java
92-
ScaleConfig.create(this,
93-
1080, // 设计宽
94-
1920, // 设计高
95-
3, // 设计像素密度
96-
ScaleConfig.DIMENS_UNIT_DP); // 填入的是 dp or pix
97-
```
98-
99-
### 接入
100-
101-
只需要把 FrameLayout,LinearLayout,RelativeLayout 换成 ScaleFrameLayout,ScaleLinearLayout,ScaleRelativeLayout 即可。
102-
103-
### 注意事项
104-
105-
1. 建议缩放方式
106-
上下滑动的界面按**屏幕宽**等比缩放
107-
左右滑动的界面按**屏幕高**等比缩放
108-
109120
## License
110121

111122
MIT

Sample/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ android {
2020
}
2121

2222
dependencies {
23-
compile project(':ScaleLayout')
24-
// compile 'cn.gavinliu.android.lib:ScaleLayout:1.0.1'
23+
// compile project(':ScaleLayout')
24+
compile 'cn.gavinliu.android.lib:ScaleLayout:1.0.2'
2525

2626
compile 'com.android.support:appcompat-v7:24.2.0'
2727
}

ScaleLayout/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
defaultConfig {
88
minSdkVersion 9
99
targetSdkVersion 24
10-
versionCode 2
11-
versionName "1.0.1"
10+
versionCode 3
11+
versionName "1.0.2"
1212
}
1313
buildTypes {
1414
release {
@@ -28,7 +28,7 @@ apply plugin: 'com.jfrog.bintray'
2828
def siteUrl = 'https://github.com/gavinliu/Android-ScaleLayout' // 项目的主页
2929
def gitUrl = 'https://github.com/gavinliu/Android-ScaleLayout.git' // Git仓库的url
3030

31-
version = "1.0.1"
31+
version = "1.0.2"
3232
group = "cn.gavinliu.android.lib"
3333

3434
install {

0 commit comments

Comments
 (0)