Giter Site home page Giter Site logo

stickerview's Introduction

Android Arsenal StickerView

A view which can add sticker and zoom,drag,flip,delete it

I hope you can copy the source code to your project so you can design your own function.

Screenshots

Usage

Suggestion

copy the source code to your project so you can design your own function.

Tips:StickerView extends FrameLayout

In layout

<com.xiaopo.flying.sticker.StickerView
        android:id="@+id/sticker_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center">
    <!-- custom, maybe you will like to put an ImageView--> 
    <ImageView
        android:src="@drawable/haizewang_2"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</com.xiaopo.flying.sticker.StickerView>

Add sticker

If the sticker is drawable, it's intrinsic width and height can not be zero. If the sticker is text, you can set text color, font and alignment and the region which holds the text.

stickerView.addSticker(sticker)
stickerView.replace(sticker)
stickerView.remove(sticker)
stickerView.removeCurrentSticker()
stickerView.removeAllStickers()
stcikerView.setLocked(true)

Also you can custom the icon and icon event and position

 BitmapStickerIcon heartIcon =
        new BitmapStickerIcon(ContextCompat.getDrawable(this, R.drawable.ic_favorite_white_24dp),
            BitmapStickerIcon.LEFT_BOTTOM);
heartIcon.setIconEvent(new HelloIconEvent());

stickerView.setIcons(Arrays.asList(deleteIcon, zoomIcon, flipIcon, heartIcon));

Update

  • 2016/10/11 Add horizontal flip function.
  • 2016/10/12 Add Lock function to disable handle stickers.
  • 2016/11/30 Added text stickers which supports both text and image background. Thanks to taoliuh.
  • 2016/12/02 Fixed the region of sticker bigger bug,and add more custom configure.
  • 2016/12/03 Add more callback
  • 2016/12/14 Add PhotoView support.
  • 2016/12/15 Add remove methods.
  • 2016/12/16 Add Double Tap Callback
  • 2016/12/17 Add Constrain Sticker's move area
  • 2017/02/07 Custom your icon and icon event
  • 2017/04/25 Fix scale err and add more useful function

Todo

  • Constrain the sticker's moving area
  • Add Double Tap callback

Licence

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.

stickerview's People

Contributors

bmonjoie avatar chenvivi avatar dryaz avatar hotstu avatar le-g avatar qb-pengliu avatar taoliuh avatar wuapnjie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stickerview's Issues

Edit Sticker Text on Double Tab

How can I edit sticker text on Double Tab of Sticker view it will help to edit that sticker text can you please help me how should I integrate it in android

Stop showing BitmapStickerIcon once clicked outside any sticker view

Stop showing BitmapStickerIcon once clicked outside any sticker view

when we select a sticker we see the BitmapStickerIcon for that sticker and if we select a different sticker it shows BitmapStickerIcon for that sticker (and it keeps on showing it), there is no fuctionality , if we click outside all or any sticker the BitmapStickerIcon should not be shown.

this is an example

https://raw.githubusercontent.com/nimengbo/StickerView/master/stickerGIF.gif

https://camo.githubusercontent.com/e29f051d1c2767eb631746f50acbf286b610a8a3/687474703a2f2f692e67697068792e636f6d2f336f37544b4a68425a69696d4165364a44472e676966

and also can we change font and fontcolor after a textsticker is set like in the gif

文字内容换行问题。

情景:设置内容为一个短语时,有一两个文字超出范围换行了,收到拉长调整,超出内容的文字没有回到一行。个人觉得能根据内容是否回车或者\n等调整更好。

Not able to get Bitmap with Sticker

Hi, I'm using this library but I need then to share the image created with the stickers, but the createBitmap is not working. Also tried to use the setLocked method (if was something with that, but no luck)

stickerView.setLocked(true); Bitmap stickerViewBitmap = stickerView.createBitmap();

Can you please help me on this one?
Thanks

How to load sticker from drawable folder and set it to StickerView.

when i change color of first sticker it replaces with second and both have same text and color when i and joint one another, they look-like only one sticker but when we close on another still on canvas how to solve it?

my code example is here

public static void AddTextColor(@nonnull Sticker sticker, int color) {

    if (sticker instanceof TextSticker) {
        ((TextSticker) sticker).setTextColor(color);
    }   
}

private void viewColorPicker() {

    ColorPickerDialogBuilder
            .with(this)
            .setTitle("Text Color")
            .initialColor(Color.parseColor("#ffffff"))
            .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
            .density(12)
            .setOnColorSelectedListener(new OnColorSelectedListener() {
                @Override
                public void onColorSelected(int selectedColor) {

                }
            })
            .setPositiveButton("ok", new ColorPickerClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
                    AddTextColor(sticker11, selectedColor);
                    stickerView.replace(sticker11);
                    if (allColors != null) {
                        StringBuilder sb = null;

                        for (Integer color : allColors) {
                            if (color == null)
                                continue;
                            if (sb == null)
                                sb = new StringBuilder("Color List:");
                            sb.append("\r\n#" + Integer.toHexString(color).toUpperCase());
                        }
                    }
                }
            })
            .setNegativeButton("cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            })
            .showColorEdit(true)
            .setColorEditTextColor(ContextCompat.getColor(this, android.R.color.holo_blue_bright))
            .build()
            .show();
}

Thank you

Drawable Multiple Stickers Added

Hello
I added multiple drawable stickers. The one on the top is always the one that is handled until removed the second one behind will be handled. The drawable stickers are not full screen sizes.

In StickerView.getCurrentSticker.setMatrix() not works. Sticker always stay on center position

I am developing application i which we can store sticker matrix positions in internal storage and restore sticker using old matrix position.
In that i get matrix value in float array of size 9 and restore it by float array but still always sticker added in center position.
After that i tried to replace sticker with setMatrix method but still it can't change position pragmatically.
So Please help me store and retrieve sticker positions.

Cannot set two different colors for same drawable

Hi,

I am using this code to add sticker from drawables:
`public void addStickerView(String string) {
Drawable drawable =
ContextCompat.getDrawable(context, getResources().getIdentifier(string, "drawable", getPackageName()));
stickerView.addSticker(new DrawableSticker(drawable));
}
public void setColor(int color) {
if(currentSticker instanceof TextSticker){
((TextSticker) currentSticker).setTextColor(color);
} else {
currentSticker.getDrawable().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
}
stickerView.invalidate();
}

public void somefunction(){
addStickerView("image");
// Setting currentSticker as above added sticker
setColor(Color.RED);
addStickerView("image");
}
`

Here I am adding "R.drawable.image" two times, but as per code only first sticker should have red color and other should have default color. But on running, both images have RED color.

Please tell me how to fix it.

TextSticker

Hello,
I am trying to change the initial position of the TextSticker.
I tried to change the position in StickerView class in addSticker(). I change the values passed to sticker.getMatrix().postTranslate(x, y), but the position is not changing.

关于竖向显示文字

我给每个字都加了\n之后,虽然画出来是竖着的,但是边框的计算貌似还是按照横向计算的,这应该怎么处理呢

How can i add bringback to front and on second click front to back on hearticon click?

public class HelloIconEvent implements StickerIconEvent{
@OverRide public void onActionDown(StickerView stickerView, MotionEvent event) {

}

@OverRide public void onActionMove(StickerView stickerView, MotionEvent event) {
}

@OverRide public void onActionUp(StickerView stickerView, MotionEvent event) {
stickerView.setBringToFrontCurrentSticker(true);

// Toast.makeText(stickerView.getContext(), "Hello World!", Toast.LENGTH_SHORT).show();

}
}

java.lang.NullPointerException on Stickerview

Love your amazing library, but got following issue. Can you please try to solve this error, it will be great help

Some Details:
Manufacturer Samsung
Android version Android 4.4
RAM (MB) 1024
Screen size 540 × 960
Screen density (dpi) 240
OpenGL ES version 3.0
Native platform armeabi-v7a
CPU make Qualcomm
CPU model MSM8216
Model galaxy grand prime

Note:
In almost every device user got this error, there is no such way to regenerate but if we try to move and rotate sticker for long time then this happens.

Stack Trace:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.PointF com.xiaopo.flying.sticker.Sticker.getMappedCenterPoint()' on a null object reference
at com.xiaopo.flying.sticker.StickerView.calculateMidPoint(StickerView.java:325)
at com.xiaopo.flying.sticker.StickerView.onTouchEvent(StickerView.java:190)
at android.view.View.dispatchTouchEvent(View.java:8725)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2606)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2266)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2606)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2266)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2606)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2266)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2606)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2266)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2606)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2266)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2606)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2266)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2545)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1745)
at android.app.Activity.dispatchTouchEvent(Activity.java:2834)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2506)
at android.view.View.dispatchPointerEvent(View.java:8915)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4098)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3961)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3523)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3576)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3542)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3652)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3550)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3709)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3523)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3576)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3542)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3550)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3523)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5795)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5769)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5740)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5885)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:143)
at android.os.Looper.loop(Looper.java:122)
at android.app.ActivityThread.main(ActivityThread.java:5753)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)

how to remove border or icon?

i want to remove border and icon like remove, flip or resize on click of out of the text sticker and show again when i click on text again how can i get this?

Sticker-view reset all sticker to middle of screen

i've an issue
i user dialog with custom layout contains edit text to add Text Sticker
the problem is after return from the dialog to the main activity that contain the sticker view all added sticker return to the middle of the activity
as if it was loaded on activity load
can any one please help me how to resolve this issue

Add to project error

I tried to add this library as a gradle project, but it gives an error of -
Error:(35, 0) Plugin with id 'com.github.dcendents.android-maven' not found.
Please how do i go about this..Thanks for the amazing library and anticipated support.

Constraining Sticker to image boundaries

Is there a way to constrain user in moving a sticker, so he couldn't be able to move it outside of the parent image view?

I am grateful for any help and advice.

Keep up the good work. :)

how to control the text size for TextSticker

can any one advise on how to control the text size for the TextStikcer
i try to add custom method to set the test size but i see no changes
what i need to do is have something like scroll for size change when the user use it the text size for selected Stikcer changes according to the value of the scroll bar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.