Skip to content

Commit

Permalink
fix preview的问题,由check design size 导致
Browse files Browse the repository at this point in the history
  • Loading branch information
hongyangAndroid committed Dec 8, 2015
1 parent c6cfc31 commit fc02f1d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 5 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies {

```
dependencies {
compile 'com.zhy:autolayout:1.3.3'
compile 'com.zhy:autolayout:1.3.4'
}
```

Expand Down Expand Up @@ -104,6 +104,27 @@ dependencies {
* textSize


## 预览

大家都知道,写布局文件的时候,不能实时的去预览效果,那么体验真的是非常的不好,也在很大程度上降低开发效率,所以下面教大家如何用好,用对PreView(针对该库)。

首先,你要记得你设计稿的尺寸,比如 `768 * 1280`

然后在你的PreView面板,选择于设计图分辨率一致的设备:


<img src="autolayout_07.png" width="480px"/>

然后你就可以看到`最为精确的`预览了:

<img src="autolayout_06.png" width="480px"/>

两个注意事项:

1. 你们UI给的设计图的尺寸并非是主流的设计图,该尺寸没找到,你可以自己去新建一个设备。
2. 不要在PreView中去查看所有分辨率下的显示,是看不出来适配效果的,因为有些计算是动态的。


## 注意事项

### ListView、RecyclerView类的Item的适配
Expand Down
2 changes: 1 addition & 1 deletion autolayout/autolayout.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":autolayout" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.zhy" external.system.module.version="1.3.2" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":autolayout" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.zhy" external.system.module.version="1.3.3" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down
2 changes: 1 addition & 1 deletion autolayout/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

version = "1.3.3"
version = "1.3.4"

android {
compileSdkVersion 23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.zhy.autolayout.config.AutoLayoutConifg;
import com.zhy.autolayout.utils.AutoLayoutHelper;

public class AutoFrameLayout extends FrameLayout
Expand Down Expand Up @@ -52,7 +53,9 @@ public LayoutParams generateLayoutParams(AttributeSet attrs)
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
if (!isInEditMode())
{
mHelper.adjustChildren();
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

Expand All @@ -70,6 +73,7 @@ public static class LayoutParams extends FrameLayout.LayoutParams
public LayoutParams(Context c, AttributeSet attrs)
{
super(c, attrs);

mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ private void initAutoLayoutConfig(ViewGroup host)

public void adjustChildren()
{
AutoLayoutConifg.getInstance().checkParams();

for (int i = 0, n = mHost.getChildCount(); i < n; i++)
{
View view = mHost.getChildAt(i);
Expand All @@ -122,8 +124,6 @@ public static AutoLayoutInfo getAutoLayoutInfo(Context context,
AttributeSet attrs)
{

AutoLayoutConifg.getInstance().checkParams();

AutoLayoutInfo info = new AutoLayoutInfo();

TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AutoLayout_Layout);
Expand Down
Binary file added autolayout_06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added autolayout_07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc02f1d

Please sign in to comment.