diff --git a/app/src/main/java/com/yalantis/fitfilter/ExampleActivity.java b/app/src/main/java/com/yalantis/fitfilter/ExampleActivity.java index 9375e0a..bdec4d0 100755 --- a/app/src/main/java/com/yalantis/fitfilter/ExampleActivity.java +++ b/app/src/main/java/com/yalantis/fitfilter/ExampleActivity.java @@ -1,5 +1,6 @@ package com.yalantis.fitfilter; +import android.graphics.Color; import android.os.Bundle; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; @@ -52,6 +53,7 @@ protected void onCreate(Bundle savedInstanceState) { mFilter.setNoSelectedItemText(getString(R.string.str_all_selected)); mFilter.build(); + mRecyclerView = (RecyclerView) findViewById(R.id.list); mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); mRecyclerView.setAdapter(mAdapter = new QuestionsAdapter(this, mAllQuestions = getQuestions())); diff --git a/filter/src/main/java/com/yalantis/filter/widget/CollapsedFilterContainer.kt b/filter/src/main/java/com/yalantis/filter/widget/CollapsedFilterContainer.kt index d62a7b7..3461f9f 100755 --- a/filter/src/main/java/com/yalantis/filter/widget/CollapsedFilterContainer.kt +++ b/filter/src/main/java/com/yalantis/filter/widget/CollapsedFilterContainer.kt @@ -1,6 +1,7 @@ package com.yalantis.filter.widget import android.content.Context +import android.graphics.Color import android.util.AttributeSet import android.view.LayoutInflater import android.view.MotionEvent @@ -19,6 +20,12 @@ class CollapsedFilterContainer : RelativeLayout { private var mStartX = 0f private var mStartY = 0f + var containerBackground = Color.WHITE + set(value) { + field = value + relative_container.setBackgroundColor(value) + } + constructor(context: Context) : this(context, null) constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0) constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(context, attrs, defStyleRes) { diff --git a/filter/src/main/java/com/yalantis/filter/widget/Filter.kt b/filter/src/main/java/com/yalantis/filter/widget/Filter.kt index 8760d8a..852c0ad 100755 --- a/filter/src/main/java/com/yalantis/filter/widget/Filter.kt +++ b/filter/src/main/java/com/yalantis/filter/widget/Filter.kt @@ -20,6 +20,10 @@ import kotlinx.android.synthetic.main.collapsed_container.view.* import kotlinx.android.synthetic.main.filter.view.* import java.io.Serializable import java.util.* +import android.content.res.TypedArray +import android.graphics.Color +import android.support.annotation.ColorInt + /** * Created by galata on 08.09.16. @@ -43,6 +47,20 @@ class Filter : FrameLayout, FilterItemListener, CollapseListene collapseView.setHasText(value) } + var collapsedBackground: Int = Color.WHITE + set(value) { + field = value + collapsedContainer.containerBackground = value + collapsedContainer.invalidate() + } + + var expandedBackground: Int = Color.WHITE + set(value) { + field = value + expandedFilter.setBackgroundColor(value) + expandedFilter.invalidate() + } + private var mIsBusy = false private var isCollapsed: Boolean? = null @@ -66,6 +84,13 @@ class Filter : FrameLayout, FilterItemListener, CollapseListene collapsedFilter.scrollListener = this collapsedContainer.listener = this expandedFilter.listener = this + val attributes = context.obtainStyledAttributes(attrs, R.styleable.Filter, 0, 0) + try { + collapsedContainer.containerBackground = attributes.getColor(R.styleable.Filter_collapsedBackground, Color.WHITE) + expandedFilter.setBackgroundColor(attributes.getColor(R.styleable.Filter_expandedBackground, Color.WHITE)) + } finally { + attributes.recycle() + } } fun build() { diff --git a/filter/src/main/res/layout/collapsed_container.xml b/filter/src/main/res/layout/collapsed_container.xml index 1279e06..ea60ed2 100755 --- a/filter/src/main/res/layout/collapsed_container.xml +++ b/filter/src/main/res/layout/collapsed_container.xml @@ -1,6 +1,7 @@ diff --git a/filter/src/main/res/values/attrs.xml b/filter/src/main/res/values/attrs.xml new file mode 100644 index 0000000..f226f94 --- /dev/null +++ b/filter/src/main/res/values/attrs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file