Skip to content

Commit 71d3532

Browse files
committed
new preset styles
2 parents 47da2f1 + 9e7371c commit 71d3532

File tree

7 files changed

+109
-44
lines changed

7 files changed

+109
-44
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,26 @@ If you are using Android Studio, just add a one line code to your project root `
1818

1919
```groovy
2020
dependencies{
21+
<<<<<<< HEAD
2122
compile 'com.daimajia.slider:library:1.0.4@aar'
23+
=======
24+
compile 'com.daimajia.slider:library:1.0.3@aar'
25+
>>>>>>> styles
2226
}
2327
```
2428

29+
2530
If you are using maven to manage your project, add below to your `pom.xml`
2631

2732
```xml
2833
<dependency>
2934
<groupId>com.daimajia.slider</groupId>
3035
<artifactId>library</artifactId>
36+
<<<<<<< HEAD
3137
<version>1.0.4</version>
38+
=======
39+
<version>1.0.3</version>
40+
>>>>>>> styles
3241
<type>apklib</type>
3342
</dependency>
3443
```

demo/src/main/res/layout/activity_main.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
custom:unselected_height="6dp"
3636
android:layout_marginBottom="20dp"
3737
/>
38-
38+
<com.daimajia.slider.library.Indicators.PagerIndicator
39+
android:id="@+id/custom_indicator_2"
40+
style="@style/AndroidImageSlider_Magnifier_Oval_Black"
41+
android:layout_centerHorizontal="true"
42+
android:layout_alignParentBottom="true"
43+
android:layout_marginBottom="20dp"
44+
/>
3945
<ListView
4046
android:layout_below="@+id/slider"
4147
android:id="@+id/transformers"

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
# org.gradle.parallel=true
1919

2020

21-
VERSION_NAME=1.0.3
22-
VERSION_CODE=4
21+
VERSION_NAME=1.0.4
22+
VERSION_CODE=5
2323
GROUP=com.daimajia.slider
2424

2525
POM_DESCRIPTION=An amazing and convenient Android image slider.

library/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
defaultConfig {
88
minSdkVersion 8
99
targetSdkVersion 19
10-
versionCode 4
11-
versionName "1.0.3"
10+
versionCode 5
11+
versionName "1.0.4"
1212
}
1313
buildTypes {
1414
release {

library/src/main/java/com/daimajia/slider/library/Indicators/PagerIndicator.java

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,15 @@ public PagerIndicator(Context context, AttributeSet attrs) {
158158
mPadding_top = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_padding_top,(int)pxFromDp(0));
159159
mPadding_bottom = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_padding_bottom,(int)pxFromDp(0));
160160

161-
mPadding_left = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_padding_left,(int)pxFromDp(3));
162-
mPadding_right = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_padding_right,(int)pxFromDp(3));
163-
mPadding_top = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_padding_top,(int)pxFromDp(0));
164-
mPadding_bottom = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_padding_bottom,(int)pxFromDp(0));
161+
mSelectedPadding_Left = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_selected_padding_left,(int)mPadding_left);
162+
mSelectedPadding_Right = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_selected_padding_right,(int)mPadding_right);
163+
mSelectedPadding_Top = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_selected_padding_top,(int)mPadding_top);
164+
mSelectedPadding_Bottom = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_selected_padding_bottom,(int)mPadding_bottom);
165165

166-
mSelectedPadding_Left = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_selected_padding_left,(int)pxFromDp(3));
167-
mSelectedPadding_Right = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_selected_padding_right,(int)pxFromDp(3));
168-
mSelectedPadding_Top = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_selected_padding_top,(int)pxFromDp(0));
169-
mSelectedPadding_Bottom = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_selected_padding_bottom,(int)pxFromDp(0));
170-
171-
mUnSelectedPadding_Left = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_unselected_padding_left,(int)pxFromDp(3));
172-
mUnSelectedPadding_Right = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_unselected_padding_right,(int)pxFromDp(3));
173-
mUnSelectedPadding_Top = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_unselected_padding_top,(int)pxFromDp(0));
174-
mUnSelectedPadding_Bottom = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_unselected_padding_bottom,(int)pxFromDp(0));
166+
mUnSelectedPadding_Left = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_unselected_padding_left,(int)mPadding_left);
167+
mUnSelectedPadding_Right = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_unselected_padding_right,(int)mPadding_right);
168+
mUnSelectedPadding_Top = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_unselected_padding_top,(int)mPadding_top);
169+
mUnSelectedPadding_Bottom = attributes.getDimensionPixelSize(R.styleable.PagerIndicator_unselected_padding_bottom,(int)mPadding_bottom);
175170

176171
mSelectedLayerDrawable = new LayerDrawable(new Drawable[]{mSelectedGradientDrawable});
177172
mUnSelectedLayerDrawable = new LayerDrawable(new Drawable[]{mUnSelectedGradientDrawable});
@@ -183,7 +178,6 @@ public PagerIndicator(Context context, AttributeSet attrs) {
183178
setDefaultUnselectedIndicatorSize(mDefaultUnSelectedWidth,mDefaultUnSelectedHeight,Unit.Px);
184179
setDefaultIndicatorColor(mDefaultSelectedColor, mDefaultUnSelectedColor);
185180
setIndicatorVisibility(mVisibility);
186-
setDefaultPadding(mPadding_left,mPadding_top,mPadding_right,mPadding_bottom,Unit.Px);
187181
setDefaultSelectedPadding(mSelectedPadding_Left,mSelectedPadding_Top,mSelectedPadding_Right,mSelectedPadding_Bottom,Unit.Px);
188182
setDefaultUnSelectedPadding(mUnSelectedPadding_Left,mUnSelectedPadding_Top,mUnSelectedPadding_Right,mUnSelectedPadding_Bottom,Unit.Px);
189183
attributes.recycle();
@@ -194,53 +188,37 @@ public enum Shape{
194188
}
195189

196190
public void setDefaultPadding(float left,float top, float right, float bottom,Unit unit){
191+
setDefaultSelectedPadding(left,top,right,bottom,unit);
192+
setDefaultUnSelectedPadding(left,top,right,bottom,unit);
193+
}
194+
195+
public void setDefaultSelectedPadding(float left,float top, float right, float bottom,Unit unit){
197196
if(unit == Unit.DP){
198197
mSelectedLayerDrawable.setLayerInset(0,
199198
(int)pxFromDp(left),(int)pxFromDp(top),
200199
(int)pxFromDp(right),(int)pxFromDp(bottom));
201-
mUnSelectedLayerDrawable.setLayerInset(0,
202-
(int)pxFromDp(left),(int)pxFromDp(top),
203-
(int)pxFromDp(right),(int)pxFromDp(bottom));
204200
}else{
205201
mSelectedLayerDrawable.setLayerInset(0,
206202
(int)left,(int)top,
207203
(int)right,(int)bottom);
208-
mUnSelectedLayerDrawable.setLayerInset(0,
209-
(int)left,(int)top,
210-
(int)right,(int)bottom);
204+
211205
}
212206
}
213207

214-
public void setDefaultSelectedPadding(float left,float top, float right, float bottom,Unit unit){
208+
public void setDefaultUnSelectedPadding(float left,float top, float right, float bottom, Unit unit){
215209
if(unit == Unit.DP){
216-
mSelectedLayerDrawable.setLayerInset(0,
210+
mUnSelectedLayerDrawable.setLayerInset(0,
217211
(int)pxFromDp(left),(int)pxFromDp(top),
218212
(int)pxFromDp(right),(int)pxFromDp(bottom));
219213

220214
}else{
221-
mSelectedLayerDrawable.setLayerInset(0,
215+
mUnSelectedLayerDrawable.setLayerInset(0,
222216
(int)left,(int)top,
223217
(int)right,(int)bottom);
224218

225219
}
226220
}
227221

228-
public void setDefaultUnSelectedPadding(float left,float top, float right, float bottom,Unit unit){
229-
if(mUserSetSelectedIndicatorResId == 0){
230-
if(unit == Unit.DP){
231-
mUnSelectedLayerDrawable.setLayerInset(0,
232-
(int)pxFromDp(left),(int)pxFromDp(top),
233-
(int)pxFromDp(right),(int)pxFromDp(bottom));
234-
235-
}else{
236-
mUnSelectedLayerDrawable.setLayerInset(0,
237-
(int)left,(int)top,
238-
(int)right,(int)bottom);
239-
240-
}
241-
}
242-
}
243-
244222
/**
245223
* if you are using the default indicator, this method will help you to set the shape of
246224
* indicator, there are two kind of shapes you can set, oval and rect.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item>
4+
<shape android:shape="rectangle">
5+
<corners android:radius="12dp"/>
6+
<solid android:color="#33000000"/>
7+
</shape>
8+
</item>
9+
</layer-list>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<style name="AndroidImageSlider_Corner_Oval_Orange">
4+
<item name="android:layout_width">wrap_content</item>
5+
<item name="android:layout_height">wrap_content</item>
6+
<item name="android:gravity">center</item>
7+
<item name="android:background">@drawable/indicator_corner_bg</item>
8+
<item name="android:paddingLeft">2dp</item>
9+
<item name="android:paddingRight">2dp</item>
10+
<item name="shape">oval</item>
11+
<item name="padding_left">3dp</item>
12+
<item name="padding_right">3dp</item>
13+
<item name="padding_top">4dp</item>
14+
<item name="padding_bottom">4dp</item>
15+
16+
<item name="selected_color">#f60</item>
17+
<item name="unselected_color">#ffffff</item>
18+
<item name="selected_width">6dp</item>
19+
<item name="selected_height">6dp</item>
20+
<item name="unselected_width">6dp</item>
21+
<item name="unselected_height">6dp</item>
22+
</style>
23+
24+
<style name="AndroidImageSlider_Attractive_Rect_Blue">
25+
<item name="android:layout_width">wrap_content</item>
26+
<item name="android:layout_height">wrap_content</item>
27+
<item name="android:gravity">center</item>
28+
<item name="android:paddingLeft">2dp</item>
29+
<item name="android:paddingRight">2dp</item>
30+
<item name="shape">rect</item>
31+
<item name="padding_left">3dp</item>
32+
<item name="padding_right">3dp</item>
33+
<item name="padding_top">4dp</item>
34+
<item name="padding_bottom">4dp</item>
35+
36+
<item name="selected_color">#30CCE5</item>
37+
<item name="unselected_color">#333333</item>
38+
<item name="selected_width">13dp</item>
39+
<item name="selected_height">4dp</item>
40+
<item name="unselected_width">13dp</item>
41+
<item name="unselected_height">4dp</item>
42+
</style>
43+
44+
<style name="AndroidImageSlider_Magnifier_Oval_Black">
45+
<item name="android:layout_width">wrap_content</item>
46+
<item name="android:layout_height">wrap_content</item>
47+
<item name="android:gravity">center</item>
48+
<item name="android:paddingLeft">2dp</item>
49+
<item name="android:paddingRight">2dp</item>
50+
<item name="shape">oval</item>
51+
<item name="padding_left">3dp</item>
52+
<item name="padding_right">3dp</item>
53+
<item name="padding_top">4dp</item>
54+
<item name="padding_bottom">4dp</item>
55+
56+
<item name="selected_color">#333333</item>
57+
<item name="unselected_color">#33000000</item>
58+
<item name="selected_width">8dp</item>
59+
<item name="selected_height">8dp</item>
60+
<item name="unselected_width">6dp</item>
61+
<item name="unselected_height">6dp</item>
62+
</style>
63+
</resources>

0 commit comments

Comments
 (0)