У меня есть следующий XML файл -
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_marketplace_root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="7dp">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
app:layout_scrollFlags="scroll">
<LinearLayout
android:id="@+id/fragment_marketplace_main_linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:orientation="vertical">
<com.twoverte.views.ClearableAutoCompleteTextView
android:id="@+id/fragment_marketplace_searchview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="14dp"
android:completionThreshold="0"
android:hint="@string/fragment_marketplace_search_hint"
android:iconifiedByDefault="false"
android:inputType="text|textAutoCorrect"
android:maxLength="25"
android:textIsSelectable="false"
android:textSelectHandle="@xml/empty_shape"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="1dp" />
<TextView
android:id="@+id/fragment_marketplace_discover_products_from_myverte_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginTop="15dp"
android:fontFamily="@font/noto_sans"
android:text="@string/fragment_marketplace_discover_products_from_myverte"
android:textSize="17sp" />
<androidx.core.widget.NestedScrollView
android:id="@+id/fragment_marketplace_vendors_nested_scrollview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/fragment_marketplace_vendors_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginEnd="14dp"
android:orientation="horizontal"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/fragment_marketplace_vendor_row_item" />
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/fragment_marketplace_featured_products_nested_scroll_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/fragment_marketplace_featured_products_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/very_light_grey"
android:fontFamily="@font/noto_sans"
android:paddingStart="14dp"
android:paddingLeft="14dp"
android:paddingTop="15dp"
android:paddingEnd="14dp"
android:text="@string/fragment_marketplace_featured_products"
android:textSize="17sp"
android:visibility="gone"
tools:visibility="visible" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/fragment_marketplace_products_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@color/very_light_grey"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="@layout/fragment_marketplace_products_row_item" />
<View
android:id="@+id/activity_product_page_bottom_view"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginTop="60dp"
android:background="@color/light_black"
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
И мне нужно создать эффект свертывания ТОЛЬКО для верхнего RV.
Так что я создал CollapsingToolbarLayout для всего, что выше RV и добавил их, но по какой-то причине мой пользовательский TextView и нормальные частично видны -
Виден только мой пользовательский TextView без намека и автозавершения цвета полностью противоположны тем, какими они должны быть.
Вот мой пользовательский TextView -
public class ClearableAutoCompleteTextView extends androidx.appcompat.widget.AppCompatAutoCompleteTextView {
// was the text just cleared?
boolean justCleared = false;
//for removing keyboard after clearing. Use setter method to instantiate
private Activity activity;
// if not set otherwise, the default clear listener clears the text in the
// text view
private OnClearListener defaultClearListener = () -> {
ClearableAutoCompleteTextView et = ClearableAutoCompleteTextView.this;
et.setText("");
};
private OnClearListener onClearListener = defaultClearListener;
// The image we defined for the clear button
public Drawable imgClearButton = getResources().getDrawable(R.drawable.bs_ic_clear_light);
public interface OnClearListener {
void onClear();
}
@Override
public boolean enoughToFilter() {
return true;
}
/* Required methods, not used in this implementation */
public ClearableAutoCompleteTextView(Context context) {
super(context);
init();
}
/* Required methods, not used in this implementation */
public ClearableAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
/* Required methods, not used in this implementation */
public ClearableAutoCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
void init() {
// if the clear button is pressed, fire up the handler. Otherwise do nothing
this.setOnTouchListener((v, event) -> {
ClearableAutoCompleteTextView et = ClearableAutoCompleteTextView.this;
if (et.getCompoundDrawables()[2] == null)
return false;
if (event.getAction() != MotionEvent.ACTION_UP)
return false;
if (event.getX() > et.getWidth() - et.getPaddingRight() - imgClearButton.getIntrinsicWidth()) {
onClearListener.onClear();
justCleared = true;
}
if (activity != null) {
KeyboardUtils.hideKeyboard(activity);
//TODO - view requests focus back after clear and keyboard pops up, handle it.
}
return false;
});
}
public void setImgClearButton(Drawable imgClearButton) {
this.imgClearButton = imgClearButton;
}
public void setOnClearListener(final OnClearListener clearListener) {
this.onClearListener = clearListener;
}
public void hideClearButton() {
this.setCompoundDrawables(null, null, null, null);
}
public void showClearButton() {
this.setCompoundDrawablesWithIntrinsicBounds(null, null, imgClearButton, null);
}
public void setActivity(Activity activity) {
this.activity = activity;
}
}
Это должно быть связано с изменением цвета, но что именно?