-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Kaufland/andcircularselect
- Loading branch information
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# andcircularselect | ||
library for customisable circular picker | ||
|
||
## Features | ||
|
||
* Easy to use - define in xml configure with Builder | ||
|
||
* highly customisable. Every part of the control can be configured | ||
|
||
|
||
## Implementation | ||
|
||
|
||
1. Add it in your root build.gradle at the end of repositories: | ||
|
||
``` | ||
buildscript { | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
... | ||
allprojects { | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
``` | ||
|
||
2. Add gradle dependency | ||
|
||
``` | ||
compile 'com.github.Kaufland:andcircularselect:0.5.0' | ||
``` | ||
|
||
3. Configure library | ||
|
||
* XML | ||
|
||
``` xml | ||
<kaufland.com.andcircularselect.CircularSelect | ||
android:layout_width="300dp" | ||
android:id="@+id/select" | ||
app:outer_circle_width="90dp" | ||
app:indicator_size="40dp" | ||
app:selector_circle_size="20dp" | ||
android:layout_marginBottom="20dp" | ||
android:layout_height="300dp"/> | ||
``` | ||
|
||
* Configure Data | ||
|
||
``` java | ||
final List<DataView> mdata = new ArrayList<>(); | ||
|
||
mdata.add(new ColorDataView.Builder().withColor(Color.BLACK).build()); | ||
mdata.add(new ColorDataView.Builder().withColor(Color.GREEN).build()); | ||
mdata.add(new ColorDataView.Builder().withColor(Color.YELLOW).build()); | ||
mdata.add(new ColorDataView.Builder().withColor(Color.BLUE).build()); | ||
mdata.add(new ColorDataView.Builder().withColor(Color.MAGENTA).build()); | ||
mdata.add(new ColorDataView.Builder().withColor(Color.LTGRAY).build()); | ||
|
||
mCircularSelect.setData(mdata); | ||
mCircularSelect.setIndicatorRenderer(new IndicatorRenderer() { | ||
|
||
private CardView mCardView; | ||
private TextView mTextView; | ||
|
||
@Override | ||
public void update(DataView selected, ViewGroup parent) { | ||
|
||
if (mCardView == null) { | ||
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); | ||
View inflated = inflater.inflate(R.layout.indicator_renderer, parent); | ||
mCardView = (CardView) inflated.findViewById(R.id.indicator_card); | ||
mTextView = (TextView) inflated.findViewById(R.id.indicator_text); | ||
} | ||
|
||
mTextView.setText(mdata.indexOf(selected) + ""); | ||
mCardView.setRadius(getResources().getDimension(R.dimen.rounded)); | ||
mCardView.setCardBackgroundColor(((ColorDataView) selected).getColor()); | ||
|
||
} | ||
}); | ||
``` |