wuapnjie / PuzzleView
- пятница, 26 августа 2016 г. в 03:13:33
Java
Android Jigsaw puzzle support
Android Jigsaw puzzle support,idea from layout for instagram
the apk file is here--->http://fir.im/puzzle0607
Due to the gif is too big, if it can not load well, you can see the demo in youtube.
in build.gradle
compile 'com.flying.xiaopo:puzzle:1.0.0'
in xml layout
<com.xiaopo.flying.puzzle.PuzzleView
android:id="@+id/puzzle"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.xiaopo.flying.puzzle.SquarePuzzleView
android:id="@+id/square_puzzle"
android:layout_width="match_parent"
android:layout_height="match_parent" />
in the java code, you can change some attributes of puzzle view
mPuzzleView.setPuzzleLayout(mPuzzleLayout);
mPuzzleView.setMoveLineEnable(true);
mPuzzleView.setNeedDrawBorder(false);
mPuzzleView.setNeedDrawOuterBorder(false);
mPuzzleView.setExtraSize(100);
mPuzzleView.setBorderWidth(4);
mPuzzleView.setBorderColor(Color.WHITE);
mPuzzleView.setSelectedBorderColor(Color.parseColor("#99BBFB"));
and handle some actions
mPuzzleView.rotate(90f);
mPuzzleView.flipHorizontally();
mPuzzleView.flipVertically();
mPuzzleView.setNeedDrawBorder(!mPuzzleView.isNeedDrawBorder());
mPuzzleView.replace(bitmap);
Also you can see the source code of demo, it will tell you how to do.
The PuzzleView depends on the PuzzleLayout. Of course you can custom it.
if you don't like to custom its layout, you can use the build-in layout.
in this demo's PlaygroundActivity, it shows all the build-in layouts. You can click to see the effect.
The custom layout also is easy. Just extends PuzzleLayout and write layout() method.
In the PuzlleLayout.class, it provides some methods to help you custom.Also you can see the source code in build-in layout to study.
public class CustomLayout extends PuzzleLayout {
@Override
public void layout() {
addLine(getOuterBorder(), Line.Direction.HORIZONTAL, 1f / 2);
addLine(getBorder(0), Line.Direction.VERTICAL, 1f / 2);
}
}
see some photo by puzzle Click here
Copyright 2016 wuapnjie
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.