Skip to content

Commit

Permalink
修复自定义drawable设置
Browse files Browse the repository at this point in the history
  • Loading branch information
shaoshuai904 committed Aug 11, 2020
1 parent b5be627 commit 6aa5771
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion app/src/main/java/com/maple/iosdialog/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.maple.iosdialog
import android.app.Activity
import android.graphics.Color
import android.os.Bundle
import android.support.v4.content.ContextCompat
import android.view.Gravity
import android.view.View
import android.widget.NumberPicker
Expand Down Expand Up @@ -146,7 +147,13 @@ class MainActivity : Activity() {
fun asrBigDataList(view: View?) {
if (ar2 == null) {
val items = getSingleSelectItemTestData(20)
ar2 = ActionSheetRecyclerDialog(this).apply {
ar2 = ActionSheetRecyclerDialog(this, ActionSheetRecyclerDialog.Config(this).apply {
titleTextSizeSp = 18f
closeDraw = ContextCompat.getDrawable(context, android.R.drawable.ic_delete)
isShowMark = true
selectMark = ContextCompat.getDrawable(context, android.R.drawable.ic_media_next)
itemTextSelectedColor = Color.RED
}).apply {
setTitle("选择条目")
addSheetItems(items)
setMaxScaleHeight(0.65)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ActionSheetRecyclerDialog(
binding.apply {
root.minimumWidth = mContext.screenInfo().x
rlTitleBar.visibility = View.GONE
ivClose.background = config.closeDraw
ivClose.setImageDrawable(config.closeDraw)
ivClose.setOnClickListener { dismiss() }
}

Expand Down Expand Up @@ -98,7 +98,7 @@ class ActionSheetRecyclerDialog(
// 设置顶部条【关闭】按钮图标
fun setCloseIcon(bg: Drawable? = config.closeDraw): ActionSheetRecyclerDialog {
binding.ivClose.let {
it.background = bg
it.setImageDrawable(bg)
it.visibility = View.VISIBLE
}
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SingleSelectItemListAdapter(
tvName.textSize = config.itemTextSizeSp
if (item.isSelected) {
tvName.setTextColor(config.itemTextSelectedColor)
ivMark.background = config.selectMark
ivMark.setImageDrawable(config.selectMark)
ivMark.visibility = if (config.isShowMark) View.VISIBLE else View.GONE
} else {
tvName.setTextColor(config.itemTextColor)
Expand Down

0 comments on commit 6aa5771

Please sign in to comment.