Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ http://www.materialdoc.com/search-filter/

<!-- Change background for the suggestions list view -->
<item name="searchSuggestionBackground">@android:color/white</item>

<!-- Change text size for edit text -->
<item name="android:textSize">@dimen/text_size_in_sp</item>

<!-- Change text color for edit text. This will also be the color of the cursor -->
<item name="android:textColor">@color/theme_primary_text_inverted</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
Expand Down Expand Up @@ -103,6 +104,10 @@ private void initStyle(AttributeSet attrs, int defStyleAttr) {
setBackground(a.getDrawable(R.styleable.MaterialSearchView_searchBackground));
}

if (a.hasValue(R.styleable.MaterialSearchView_android_textSize)) {
setTextSize(a.getDimensionPixelSize(R.styleable.MaterialSearchView_android_textSize, 0));
}

if (a.hasValue(R.styleable.MaterialSearchView_android_textColor)) {
setTextColor(a.getColor(R.styleable.MaterialSearchView_android_textColor, 0));
}
Expand Down Expand Up @@ -307,6 +312,10 @@ public void setBackgroundColor(int color) {
mSearchTopBar.setBackgroundColor(color);
}

public void setTextSize(int size) {
mSearchSrcTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
}

public void setTextColor(int color) {
mSearchSrcTextView.setTextColor(color);
}
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<attr name="searchSuggestionIcon" format="integer" />
<attr name="searchSuggestionBackground" format="integer" />
<attr name="android:hint" />
<attr name="android:textSize" />
<attr name="android:textColor" />
<attr name="android:textColorHint" />
</declare-styleable>
Expand Down