From 4f139ea457200ddaa5d908959f02bb8bd04128de Mon Sep 17 00:00:00 2001 From: Bakht Date: Mon, 10 Jul 2017 12:55:37 +0300 Subject: [PATCH] fix align PlaceHolder without navigation icon --- app/build.gradle | 8 ++++---- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- library/build.gradle | 14 +++++++------- .../materialsearchbar/MaterialSearchBar.java | 15 +++++++++++---- library/src/main/res/layout/searchbar.xml | 3 +-- library/src/main/res/values/dimens.xml | 2 ++ 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 89f300e..23b8776 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" + compileSdkVersion 25 + buildToolsVersion "25.0.3" defaultConfig { applicationId "com.mancj.example" minSdkVersion 16 - targetSdkVersion 23 + targetSdkVersion 25 versionCode 2 versionName "1.1" } @@ -24,5 +24,5 @@ dependencies { compile project(':library') compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' - testCompile 'junit:junit:4.12' +// testCompile 'junit:junit:4.12' } diff --git a/build.gradle b/build.gradle index 74b2ab0..c2eea8e 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:2.3.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 877a0b3..85e6c38 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Dec 12 09:35:06 CAT 2016 +#Mon Jul 10 11:00:23 MSK 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip diff --git a/library/build.gradle b/library/build.gradle index 0ffa07c..b7a37f1 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" + compileSdkVersion 25 + buildToolsVersion "25.0.3" defaultConfig { minSdkVersion 16 - targetSdkVersion 23 + targetSdkVersion 25 versionCode 1 versionName "0.1" } @@ -20,10 +20,10 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.4.0' - compile 'com.android.support:recyclerview-v7:23.4.0' - compile 'com.android.support:cardview-v7:23.4.0' +// testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:25.3.1' + compile 'com.android.support:recyclerview-v7:25.3.1' + compile 'com.android.support:cardview-v7:25.3.1' } // build a jar with source files diff --git a/library/src/main/java/com/mancj/materialsearchbar/MaterialSearchBar.java b/library/src/main/java/com/mancj/materialsearchbar/MaterialSearchBar.java index a7be545..92545e5 100644 --- a/library/src/main/java/com/mancj/materialsearchbar/MaterialSearchBar.java +++ b/library/src/main/java/com/mancj/materialsearchbar/MaterialSearchBar.java @@ -440,14 +440,21 @@ public void setNavButtonEnabled(boolean navButtonEnabled) { if (navButtonEnabled){ navIcon.setVisibility(VISIBLE); navIcon.setClickable(true); - LayoutParams lp = (LayoutParams) inputContainer.getLayoutParams(); - lp.leftMargin = (int) (50 * destiny); - inputContainer.setLayoutParams(lp); + navIcon.getLayoutParams().width = (int) (50 * destiny); + + ((LayoutParams) inputContainer.getLayoutParams()).leftMargin = (int) (50 * destiny); arrowIcon.setVisibility(GONE); }else { - navIcon.setVisibility(GONE); + navIcon.getLayoutParams().width = 1; + navIcon.setVisibility(INVISIBLE); navIcon.setClickable(false); + + ((LayoutParams) inputContainer.getLayoutParams()).leftMargin = (int) (0 * destiny); + arrowIcon.setVisibility(VISIBLE); } + navIcon.requestLayout(); + placeHolder.requestLayout(); + arrowIcon.requestLayout(); } /** diff --git a/library/src/main/res/layout/searchbar.xml b/library/src/main/res/layout/searchbar.xml index 3cb8978..a323bb9 100644 --- a/library/src/main/res/layout/searchbar.xml +++ b/library/src/main/res/layout/searchbar.xml @@ -10,7 +10,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> + tools:text="Hara" /> 16dp 16dp 16dp + + 50dp