Skip to content

Commit

Permalink
Fixes hint text color
Browse files Browse the repository at this point in the history
  • Loading branch information
kojofosu committed Oct 9, 2021
1 parent f84d8c5 commit 7646a10
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity() {
val binding: ActivityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main)

binding.multiSearchView.hint = "Search?"
// binding.multiSearchView.setHintTextColor("#0DD413")
// binding.multiSearchView.setHintTextColor(Color.BLUE)
// binding.multiSearchView.setSearchIconColor("#D4C50D")

binding.multiSearchView.setSearchViewListener(object : MultiSearchView.MultiSearchViewListener{
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:selectedTabStyle="line"
app:hintTextColor="@android:color/holo_orange_light"
app:searchIconColor="@android:color/holo_orange_light"
app:searchTextColor="@android:color/white"
app:clearIconColor="@android:color/white"
app:selectedTabColor="@android:color/white"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class MultiSearchContainerView @JvmOverloads constructor(
var selectedTabStyle = 0
var selectedTabSColor = Color.BLACK
var clearIconColor = Color.BLACK
var searchTextColor = Color.WHITE
var searchTextColor = Color.BLACK
var hintTextColor = Color.BLACK

var searchTextStyle = 0

Expand Down Expand Up @@ -217,6 +218,7 @@ class MultiSearchContainerView @JvmOverloads constructor(
if (hintColorStateList != null)
viewItem.editTextSearch.setHintTextColor(hintColorStateList)

viewItem.editTextSearch.setHintTextColor(hintTextColor)
viewItem.editTextSearch.setStyle(context, searchTextStyle)
viewItem.editTextSearch.setTextColor(searchTextColor)
viewItem.editTextSearch.hint = hint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,22 @@ class MultiSearchView @JvmOverloads constructor(context: Context, attrs: Attribu
val selectedTabColor = typedArray.getColor(R.styleable.MultiSearchView_selectedTabColor, Color.BLACK)
val clearIconColor = typedArray.getColor(R.styleable.MultiSearchView_clearIconColor, Color.BLACK)
val searchTextColor = typedArray.getColor(R.styleable.MultiSearchView_searchTextColor, Color.BLACK)
val hintTextColor = typedArray.getColor(R.styleable.MultiSearchView_hintTextColor, Color.GRAY)

binding.searchViewContainer.apply {
this.searchTextStyle = searchTextStyle
this.selectedTabStyle = selectedTabStyle
this.selectedTabSColor = selectedTabColor
this.clearIconColor = clearIconColor
this.searchTextColor = searchTextColor
this.hintTextColor = hintTextColor
}

setSearchIconDrawable(imageSource)
setSelectedTabColor(selectedTabColor)
setClearIconColor(clearIconColor)
setSearchTextColor(searchTextColor)
setHintTextColor(hintTextColor)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
setSearchIconColor(resources.getColor(searchIconColorResID, context.theme))
Expand Down Expand Up @@ -108,7 +111,7 @@ class MultiSearchView @JvmOverloads constructor(context: Context, attrs: Attribu
}

fun setHintTextColor(@ColorInt colorInt: Int) {
binding.searchViewContainer.hintColorStateList = ColorStateList.valueOf(colorInt)
binding.searchViewContainer.hintTextColor = colorInt
}

@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
Expand Down
1 change: 1 addition & 0 deletions multisearchviewlib/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<attr name="selectedTabColor" format="reference|color|string"/>
<attr name="clearIconColor" format="reference|color|string"/>
<attr name="searchTextColor" format="reference|color|string"/>
<attr name="hintTextColor" format="reference|color|string"/>
<!--set selected tab style-->
<attr name="selectedTabStyle" format="enum">
<enum name="line" value="0"/>
Expand Down

0 comments on commit 7646a10

Please sign in to comment.