2017-05-10 6 views
0

내 애플리케이션에서 회 전자를 사용하고 있으며 맞춤 어댑터를 사용하여 회 전자에 항목을 채 웁니다. 모든 것은 잘 동작합니다. 클릭 값, 선택 값 등을 설정하는 것과 같지만, 스피너를 스크롤하려 할 때 스피너 자체는 상단 또는 하단과 같이 기본 선택 위치로 이동합니다. 스크롤하기 위해 다시 만지 자마자 기본 선택 항목에 배치됩니다.Android 7.0에서 터치시 Spinner가 기본 선택 항목으로 스크롤합니다.

아래 코드에서 어댑터, 스피너 선언 및 스피너 항목을 찾을 수 있습니다.

Spinner.xml

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:paddingStart="8dp" 
android:paddingTop="8dp" 
android:paddingBottom="8dp"> 

    <Spinner 
     android:id="@+id/toolbar_spinner" 
     style="@style/ToolbarSpinner" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
</LinearLayout> 

spinner_item.xml 아래

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
xmlns:tools="http://schemas.android.com/tools" 
android:orientation="vertical" 
android:background="?attr/selectableItemBackground"> 

    <View 
     android:id="@+id/line_separator" 
     android:layout_width="match_parent" 
     android:layout_height="1px" 
     android:background="@color/divider" 
     android:layout_gravity="center" 
     android:paddingStart="16dp" 
     android:layout_marginLeft="8dp" 
     android:visibility="gone" 
     tools:visibility="visible"/> 

    <TextView 
     android:id="@android:id/text1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical|start|left" 
     android:paddingLeft="16dp" 
     android:paddingRight="16dp" 
     android:paddingTop="8dp" 
     android:paddingBottom="8dp" 
     android:textColor="@color/black_dropdown" 
     android:textSize="18sp" 
     android:ellipsize="end" 
     android:maxLines="1" 
     tools:text="test" 
     /> 
</LinearLayout> 

내가 스피너 어댑터 :

SpinnerAdapter adapter = new SpinnerAdapter(mHelperActivity.getSupportActionBar().getThemedContext(), item_list); 
mSpinner.setAdapter(adapter); 
mSpinner.setDropDownWidth((Utilities.getScreenWidth(getContext()) * 3)/4); 
mSpinner.setSelection(Caches.getSelectedCategoryPosition()); 

내가 정의를 설정하는 시도를 호출하는 방법을 보여줍니다 코드입니다

테마, 사용자 정의 popuptheme하지만 아무 이득.

P .: 이것은 Android 7에서만 발생하며 Android 6 이하에서는 완벽하게 작동합니다.

+0

을 사용했다 어디 entiries 값 스피너>? – Ibrahim

+0

, 스피너 어댑터 호출 내에서 item_list –

+0

'mSpinner.setDropDownWidth ((Utilities.getScreenWidth (getContext()) * 3)/4); mSpinner.setSelection (Caches.getSelectedCategoryPosition()) ' 이 코드 줄을 해시하고 시도해보십시오. 왜이 방법으로 자신을 커밋하는지 모르겠지만 ... – Ibrahim

답변

0

봅니다 저도 같은 문제가 있었다

style="@style/ToolbarSpinner"

<Spinner 
    android:id="@+id/toolbar_spinner"   
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

회에서 스타일을 제거하고 내 경우는 테마 (popupTheme 및 테마)

<Spinner android:id="@+id/spinner" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:gravity="bottom" 
        local:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
        local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
        >