VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions.

Related tags

Layout Vorolay
Overview

Vorolay

License Android Arsenal

VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions. [Voronoi diagram] (https://en.wikipedia.org/wiki/Voronoi_diagram)

Screenshots

alt text alt text alt text alt text

Import

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
        compile 'com.github.Quatja:Vorolay:1.0.1'
}

---------

Usage

Add the view into your layout. You can customize it by using xml attributes

<quatja.com.vorolay.VoronoiView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_margin="50dp"
  custom:border_color="@color/gray"
  custom:border_round="false"
  custom:border_width="5"    />

Then add your views to the VoronoiView

VoronoiView voronoiView = (VoronoiView) findViewById(R.id.voronoi);
LayoutInflater layoutInflater = getLayoutInflater();
for (int i = 0; i < 15; i++) {
    View view = layoutInflater.inflate(R.layout.item_voronoi, null, false);
    voronoiView.addView(view);
}

Now VoronoiView children will be displayed inside the diagram regions.


---------

Customization

Attributes which you can use in customization purposes

attr value/example description
show_border true shows or hides each region borders
border_color #fff sets all borders color
border_width 5 sets borders width
border_round true makes border corners round
generation_type random sets different points generation behavior

Generation types

type description
random VoronoiView generates a random point positions inside the view bounds.
ordered points are placed like a table - rows and columns.
custom points will be placed in user defined positions.

These attributes are available programmatically too.


Warning

Children visibility GONE doesn't work
Do not use tags for the children


Acknowledgements

Steven Fortune - algorithm author
Zhenyu Pan - Forutne algorithm Java version
Bart Kiers - Graham Scan realization


License

Copyright 2016 Daniil Jurjev

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.
Comments
  • Wrong View got activated when another overlapped view is clicked

    Wrong View got activated when another overlapped view is clicked

    I set up a clickListener for the views in the vorolay layout. When I click a region on an imageView that's "overlapped" by another, the other imageView is activated (see attached image).

    is there any settings I can configure?

    the following are my codes

        for (int i = 0; i < count; i++) {
            RelativeLayout rl = (RelativeLayout) layoutInflater.inflate(R.layout.item_voronoi, null, false);
    
            ImageView iv = ( ImageView) rl.findViewById(R.id.image);
    
           //add a callback when the image is clicked
            int value = i;
            iv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Log.d("TEST", "item clicked: "+ value);
                }
            }); 
    
            loadImage(iv, uri);  //this method populates the image
    
            vv.addView(rl); //this is the VoronoiView
        }  
    

    touchdetect

    opened by angelkoh 1
  • images not cropped in API19

    images not cropped in API19

    device-2017-01-10-151117

    app works correctly on emulator with API24, but is not properly cropped on an API19 (android 4.2.2) device.

    the code for adding the view is

    for (int i = 0; i < count; i++) {
            RelativeLayout rl = (RelativeLayout) layoutInflater.inflate(R.layout.item_voronoi, null, false);
            ImageView view = ( ImageView) rl.findViewById(R.id.image);  
            view.setImageURI(uri); 
            vv.addView(rl);
        }
    

    and the xml is

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
     
        <ImageView
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop" />
    
    </RelativeLayout>
    
    opened by angelkoh 1
  • what's wrong?

    what's wrong?

    1 My code: voronoiView = (VoronoiView) findViewById(R.id.voronoi); LayoutInflater layoutInflater = getLayoutInflater(); for (int i = 0; i < 15; i++) { ImageView view = (ImageView) layoutInflater.inflate(R.layout.item_iv, null, false); view.setImageResource(R.drawable.p2_480); voronoiView.addView(view); }

    opened by DearZack 1
  • Adjust grid

    Adjust grid

    Hey, first of all I would like to say this is an amazing library :) Is there a way to make it not random? as in the same picture will go to the same spot with the exact same shape every time? Even when playing with generation_type and setGenerationType it still adds random shapes

    opened by vyvital 1
  • Null Pointer Exception

    Null Pointer Exception

    Hey I've been trying to use your library but when I add it to my layout I get this error

    java.lang.NullPointerException at quatja.com.vorolay.diagram.Voronoi.addCornerEdges(Voronoi.java:167) at quatja.com.vorolay.diagram.Voronoi.getRegions(Voronoi.java:131) at quatja.com.vorolay.VoronoiView.generateDiagram(VoronoiView.java:428) at quatja.com.vorolay.VoronoiView.onSizeChanged(VoronoiView.java:321) at android.view.View.sizeChange(View.java:17638) at android.view.View.setFrame(View.java:17600) at android.view.View.layout(View.java:17517) at android.view.ViewGroup.layout(ViewGroup.java:5612) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079) at android.view.View.layout(View.java:17520) at android.view.ViewGroup.layout(ViewGroup.java:5612) at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131) at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42) at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1375) at android.support.design.widget.CoordinatorLayout.onLayout_Original(CoordinatorLayout.java:870) at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java) at android.view.View.layout(View.java:17520) at android.view.ViewGroup.layout(ViewGroup.java:5612) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17520) at android.view.ViewGroup.layout(ViewGroup.java:5612) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079) at android.view.View.layout(View.java:17520) at android.view.ViewGroup.layout(ViewGroup.java:5612) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:345) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$70(RenderTask.java:659) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

    opened by JailbirdInteractive 0
  • Can't set up ListView

    Can't set up ListView

    Not sure what's going on here but I keep getting this error untitled

    which refers to this part of the library untitled2

    This is my adapter for the listview

    package com.example.frido.rando.Utilities;
    
    import android.content.Context;
    import android.graphics.Color;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.ImageView;
    import android.widget.TextView;
    
    import com.example.frido.rando.R;
    
    import java.io.File;
    import java.util.ArrayList;
    import java.util.Random;
    
    import butterknife.BindView;
    import butterknife.ButterKnife;
    import quatja.com.vorolay.VoronoiView;
    
    public class VoronoAdapter extends BaseAdapter {
        private Context context;
        private LayoutInflater layoutInflater;
        private ArrayList<String> imageURLs;
        private File filePath;
    
        public VoronoAdapter(ArrayList<String> imageURLs, Context context) {
            this.imageURLs = imageURLs;
            this.context = context;
            this.layoutInflater = LayoutInflater.from(context);
        }
    
        @Override
        public int getCount() {
            return imageURLs.size();
        }
    
        @Override
        public Object getItem(int position) {
            return imageURLs.get(position);
        }
    
        @Override
        public long getItemId(int position) {
            return position;
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            if (convertView == null) {
                convertView = layoutInflater.inflate(R.layout.vorono_template, parent, false);
                holder = new ViewHolder(convertView);
                convertView.setTag(holder);
    
    
                for (int i = 0; i < 20; i++) {
                    View view = layoutInflater.inflate(R.layout.vorono_item_for_template, null, false);
                    holder.voronoi.addView(view);
    
                    ImageView layout = (ImageView) view.findViewById(R.id.itemVoronoLayout);
                    Random rnd = new Random();
                    int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
                    layout.setBackgroundColor(color);
                }
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
    
    
    
    
            return convertView;
        }
    
    
        static class ViewHolder{
            @BindView(R.id.voronoTemplateForList) VoronoiView voronoi;
    
    
            public ViewHolder(View view){
                ButterKnife.bind(this,view);
            }
        }
    }
    ```
    `
    opened by Frido1 1
Releases(1.0.1)
Owner
Daniil Jurjev
Daniil Jurjev
[UNMAINTAINED]: AndroidMosaicLayout is android layout to display group of views as grid consists of different asymmetric patterns (90 different patterns).

AndroidMosaicLayout AndroidMosaicLayout is android layout to display group of views in more that 90 different patterns. What is AndroidMosaicLayout? I

Adham Enaya 474 Nov 12, 2022
You don’t want your apps look and feel boring, do you? Add some bubbles!

#BubbleAnimationLayout Say hello to Bubble Animation Layout for Android by Cleveroad You don’t want your apps look and feel boring, do you? Add some b

Cleveroad 576 Nov 23, 2022
This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.

Note: we are not actively responding to issues right now. If you find a bug, please submit a PR. Android Sliding Up Panel This library provides a simp

Umano: News Read To You 9.4k Dec 31, 2022
A 3D Layout for Android,When you use it warp other view,it can became a 3D view,一秒让你的view拥有3D效果!

ThreeDLayout A 3D Layout,When you use it warp other view,it can became a 3D view 中文文档 preview USAGE 1.compile library allprojects { repositories {

androidwing 490 Oct 27, 2022
ConstraintLayout is an Android layout component which allows you to position and size widgets in a flexible way

ConstraintLayout is a layout manager for Android which allows you to position and size widgets in a flexible way. It's available for both the Android view system and Jetpack Compose.

Android Jetpack 970 Jan 6, 2023
A library that easily allows you to mask layouts/viewgroups

Maskable Layout Overview ======================= The Maskable Layout is a simple framelayout that allows you to easily mask views and viewgroups. You

Christophe Smet 654 Dec 2, 2022
It's an Android library that allows you to use Layout as RadioButton or CheckBox.

Android - CompoundLayout It's an Android library that allows you to use Layout as RadioButton or CheckBox. The librarie is Android 14+ compatible. Gra

null 483 Nov 25, 2022
null 2.4k Dec 30, 2022
Ultra Pull to Refresh for Android. Support all the views.

Welcome to follow me on GitHub or Twitter GitHub: https://github.com/liaohuqiu Twitter: https://twitter.com/liaohuqiu 中文版文档 Wanna auto-load-more? This

Huqiu Liao 9.6k Jan 5, 2023
A layout to transition between two views using a Floating Action Button as shown in many Material Design concepts

⚠ This library is no longer maintained ⚠️ FABRevealLayout A layout to transition between two views using a Floating Action Button as shown in many Mat

Tomás Ruiz-López 901 Dec 9, 2022
A pull to refresh layout for android, the RecyclerRefreshLayout is based on the SwipeRefreshLayout. support all the views, highly customizable, code simplicity, etc. really a practical RefreshLayout!

RecyclerRefreshLayout English | 中文版 RecyclerRefreshLayout based on the {@link android.support.v4.widget.SwipeRefreshLayout} The RecyclerRefreshLayout

dinus_developer 1.7k Nov 10, 2022
GoolgePlusLayout is a custom layout that plays animation on the children views while scrolling as the layout in the Google Plus (android) main page

Google Plus Layout Google Plus Layout is a custom layout that support playing animation on child view(s) in a serialize manner like the the main

Ahmed Nammari 224 Nov 25, 2022
An android layout to re-arrange child views via dragging

Android Rearrangeable Layout An android layout to re-arrange child views via dragging Screencast Demo Layout Usage All the child views are draggable o

Raja Sharan Mamidala 273 Nov 25, 2022
swipe display drawer with flowing & bouncing effects.

FlowingDrawer swipe right to display drawer with flowing effects. Download Include the following dependency in your build.gradle file. Gradle: rep

mxn 2.6k Jan 3, 2023
CircularStats - Custom Widget to display stats of any thing

CircularStats This is a custom widget made with Jetpack Compose for displaying s

null 14 Jul 2, 2022
Easily add slide to dismiss functionality to an Activity

Slidr Easily add slide-to-dismiss functionality to your Activity by calling Slidr.attach(this) in your onCreate(..) method. Usage An example usage: pu

Drew Heavner 2.7k Dec 29, 2022
Allows the easy creation of animated transition effects when the state of Android UI has changed

android-transition Android-Transition allows the easy creation of view transitions that reacts to user inputs. The library is designed to be general e

Kai 615 Nov 14, 2022
A wave view of android,can be used as progress bar.

WaveView ![Gitter](https://badges.gitter.im/Join Chat.svg) A wave view of android,can be used as progress bar. Screenshot APK demo.apk What can be use

Kai Wang 1.3k Dec 28, 2022