滚动自定义视图微调器时,会下拉其丢失的菜单项。
我尝试了所有适用于类似类型问题的建议,但没有任何效果。这是代码。
AndroidMnifest.xml
android:hardwareAccelerated =“ true” android:largeHeap =“ true”
SpinnerArray.xml
<string-array name="spinner_categories">
<item>1</item>
<item>2</item>
<item>3</item>
.
.
.
<item>15</item>
<item>16</item>
<item>17</item>
</string-array>
<string-array name="spinner_categories2">
<item>1</item>
<item>2</item>
<item>3</item>
.
.
.
<item>15</item>
<item>16</item>
<item>17</item>
</string-array>
custom_dropdown_layout.xml
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="inherit"
android:textAlignment="center"
android:textColor="#3b7878" />
Fragment.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:shimmer="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".menus.Courses">
<LinearLayout
android:id="@+id/Header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:gravity="center"
android:padding="10dp">
<Spinner
android:id="@+id/mSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:background="@drawable/bg_spinner"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/MenuView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/Header"
android:scrollbars="vertical" />
</RelativeLayout>
Fragment.java
private Spinner mySpinner;
private ArrayAdapter<CharSequence> mAdapter;
mySpinner = view.findViewById(R.id.mSpinner);
mAdapter = ArrayAdapter.createFromResource(Objects.requireNonNull(getContext()),R.array.spinner_categories, R.layout.custom_dropdown_layout);
mAdapter.setDropDownViewResource(R.layout.custom_dropdown_layout);
mySpinner.setAdapter(mAdapter);
mySpinner.setOnItemSelectedListener(this);
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Category = parent.getSelectedItem().toString();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
bg_spinner.xml
<shape android:shape="rectangle" android:useLevel="false">
<solid android:color="#00000000" />
<stroke android:width="1dp" android:color="#3b7878" />
</shape>