diff --git a/.gitignore b/.gitignore
index 39fb081..ce34337 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,67 @@
-*.iml
-.gradle
-/local.properties
-/.idea/workspace.xml
-/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
+# Built application files
+*.apk
+*.ap_
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# IntelliJ
+*.iml
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/gradle.xml
+.idea/dictionaries
+.idea/libraries
+
+# Keystore files
+# Uncomment the following line if you do not want to check your keystore files in.
+#*.jks
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+
+# Google Services (e.g. APIs or Firebase)
+google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json
+
+# fastlane
+fastlane/report.xml
+fastlane/Preview.html
+fastlane/screenshots
+fastlane/test_output
+fastlane/readme.md
diff --git a/build.gradle b/build.gradle
index a6688b0..dcba93d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.0-beta6'
+ classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/library/build.gradle b/library/build.gradle
index 52c64bf..b46a493 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,12 +1,11 @@
apply plugin: 'com.android.library'
-
android {
- compileSdkVersion 26
- buildToolsVersion '26.0.1'
+ compileSdkVersion 27
+ buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 14
- targetSdkVersion 26
+ targetSdkVersion 27
}
buildTypes {
release {
@@ -17,9 +16,12 @@ android {
dependencies {
- compile 'com.android.support:appcompat-v7:26.1.0'
- compile 'com.android.support:recyclerview-v7:26.1.0'
+ implementation 'com.android.support:appcompat-v7:27.1.0'
+ implementation 'com.android.support:recyclerview-v7:27.1.0'
}
- apply from: '../maven_push.gradle'
+ // apply from: '../maven_push.gradle'
}
+
+dependencies {
+}
\ No newline at end of file
diff --git a/library/src/main/java/fr/ganfra/materialspinner/MaterialSpinner.java b/library/src/main/java/fr/ganfra/materialspinner/MaterialSpinner.java
index 542e576..f215f35 100644
--- a/library/src/main/java/fr/ganfra/materialspinner/MaterialSpinner.java
+++ b/library/src/main/java/fr/ganfra/materialspinner/MaterialSpinner.java
@@ -101,6 +101,7 @@ public class MaterialSpinner extends AppCompatSpinner implements ValueAnimator.A
private boolean enableFloatingLabel;
private boolean alwaysShowFloatingLabel;
private boolean isRtl;
+ private int backgroundColor;
private HintAdapter hintAdapter;
@@ -147,7 +148,8 @@ private void init(Context context, AttributeSet attrs) {
initOnItemSelectedListener();
setMinimumHeight(getPaddingTop() + getPaddingBottom() + minContentHeight);
//Erase the drawable selector not to be affected by new size (extra paddings)
- setBackgroundResource(R.drawable.my_background);
+ // setBackgroundResource(R.drawable.my_background);
+ setBackgroundColor(backgroundColor);
}
@@ -183,7 +185,7 @@ private void initAttributes(Context context, AttributeSet attrs) {
isRtl = array.getBoolean(R.styleable.MaterialSpinner_ms_isRtl, false);
mHintView = array.getResourceId(R.styleable.MaterialSpinner_ms_hintView, android.R.layout.simple_spinner_item);
mDropDownHintView = array.getResourceId(R.styleable.MaterialSpinner_ms_dropDownHintView, android.R.layout.simple_spinner_dropdown_item);
-
+ backgroundColor = array.getColor(R.styleable.MaterialSpinner_ms_backgroundColor, getResources().getColor(android.R.color.transparent));
String typefacePath = array.getString(R.styleable.MaterialSpinner_ms_typeface);
if (typefacePath != null) {
typeface = Typeface.createFromAsset(getContext().getAssets(), typefacePath);
@@ -855,6 +857,15 @@ private void setCurrentNbErrorLines(float currentNbErrorLines) {
updateBottomPadding();
}
+ public int getBackgroundColor() {
+ return backgroundColor;
+ }
+
+ @Override
+ public void setBackgroundColor(int backgroundColor) {
+ this.backgroundColor = backgroundColor;
+ }
+
@Override
public Object getItemAtPosition(int position) {
if (hint != null) {
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
index 605e5e3..99ee098 100644
--- a/library/src/main/res/values/attrs.xml
+++ b/library/src/main/res/values/attrs.xml
@@ -24,6 +24,7 @@
+
\ No newline at end of file
diff --git a/sample/build.gradle b/sample/build.gradle
index 5f3ea88..ddbff08 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 26
- buildToolsVersion '26.0.1'
+ compileSdkVersion 27
+ buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'fr.ganfra.materialspinner.sample'
minSdkVersion 14
- targetSdkVersion 26
+ targetSdkVersion 27
versionCode 4
versionName '1.1.0'
}
@@ -20,6 +20,6 @@ android {
}
dependencies {
- compile 'com.android.support:appcompat-v7:26.1.0'
- compile project(':library')
+ implementation 'com.android.support:appcompat-v7:27.1.0'
+ implementation project(':library')
}
diff --git a/sample/src/main/java/fr/ganfra/materialspinner/sample/MainActivity.java b/sample/src/main/java/fr/ganfra/materialspinner/sample/MainActivity.java
index 7682a1c..f3f4dc5 100644
--- a/sample/src/main/java/fr/ganfra/materialspinner/sample/MainActivity.java
+++ b/sample/src/main/java/fr/ganfra/materialspinner/sample/MainActivity.java
@@ -22,6 +22,7 @@ public class MainActivity extends AppCompatActivity {
MaterialSpinner spinner5;
MaterialSpinner spinner6;
MaterialSpinner spinner7;
+ MaterialSpinner spinner8;
private boolean shown = false;
@@ -43,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {
initSpinnerScrolling();
initSpinnerHintAndCustomHintView();
initEmptyArray();
+ initSpinnerWithBackground();
}
@@ -85,6 +87,12 @@ private void initEmptyArray() {
spinner7.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, emptyArray));
}
+ private void initSpinnerWithBackground() {
+ spinner8 = findViewById(R.id.spinner8);
+ spinner8.setAdapter(adapter);
+ spinner8.setPaddingSafe(0, 0, 0, 0);
+ }
+
public void activateError(View view) {
if (!shown) {
spinner4.setError(ERROR_MSG);
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
index dde1045..5277cdf 100644
--- a/sample/src/main/res/layout/activity_main.xml
+++ b/sample/src/main/res/layout/activity_main.xml
@@ -67,6 +67,18 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
+
+