2016-04-01 19 views
2

Uygulamamın, bir viewpager içeren birkaç parçacığı sekmesi var ve baştan başlamıyor ve nedenini bilmiyorum. Parçayı en üste kaydırdığımda bile, ferahlatıcı (ileri ve geri sekmeler) parçanın başlangıç ​​konumunu geri dönüşümcügörünün hemen üstünde sıfırlar.parçası baştan başlatılamıyor

fragment2.xml

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:isScrollContainer="false" 
android:layout_gravity="fill_vertical" 
android:clipToPadding="false" 
android:fillViewport="true" 
android:scrollbars="none" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="79dp" 
      android:scaleType="fitXY" 
      android:src="@drawable/sub4_visual"/> 
     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="79dp" 
      android:alpha="0.3" 
      android:background="#000000"/> 
    </RelativeLayout> 
    <TextView 
     android:id="@+id/frag2_desc" 
     android:layout_margin="11dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textSize="15sp" 
     android:textColor="@color/color_333333" 
     android:text=""/> 
    <Spinner 
     android:id="@+id/frag2_dropbox" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:overScrollMode="ifContentScrolls" 
     android:scrollbars="none" 
     android:gravity="left"/> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recycler_subfrag2" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 
</LinearLayout> 

Fragment2.java

public class Fragment2 extends Fragment{ 

... 

    public static Frag_BoardContent[] fragsList; 
    public static RecyclerView mRecyclerView; 
    public static Frag234_Adapter4 board_adapter; 


    public Fragment2() { 
     // Required empty public constructor 
    } 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 
     // Inflate the layout for this fragment 
     final View v = inflater.inflate(R.layout.fragment2, container, false); 

     tv_frag2Desc = (TextView) v.findViewById(R.id.frag2_desc); 


     spinner = (Spinner) v.findViewById(R.id.frag2_dropbox); 
     ArrayList<String> categoryList = new ArrayList<>(); 
     if (connect) makeDynamicArray(categoryList); 
     adapter = new ArrayAdapter<> (getActivity(), R.layout.activity_board_spinner,categoryList); 

     spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 
      @Override 
      public void onItemSelected(final AdapterView<?> parent, final View view, int position, long id) { 
          mRecyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.context)); 
          mRecyclerView.setHasFixedSize(true); 
          mRecyclerView.setNestedScrollingEnabled(false); 
          board_adapter = new Frag234_Adapter4(MainActivity.context, fragsList); 
          mRecyclerView.setAdapter(board_adapter); 

      } 

      @Override 
      public void onNothingSelected(AdapterView<?> parent) { 
      } 
     }); 

     mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_subfrag2); 
     mRecyclerView.setAdapter(board_adapter); 



     return v; 
    } 

    public ArrayList<String> makeDynamicArray(){...} 
} 
+0

Parça en baştan başlamıyor mu? ne demek istiyorsun? Uygulamada veya parça yüklerini ilk açtığınızda ancak üst kısım görünmediğinde fragmandaki gibi yüklenmez. –

+0

Görünüm çağrı cihazınızı ve tablayout'u xml –

+1

üst kısmı görünmüyor ve üç saatliğine googling ettikten sonra buradaki cevabı buldum: http://stackoverflow.com/questions/33584187/nestedscrollview-wont-start-from-top –

cevap

0

odaklamak ilgili bir sorundur. Eğer Scrollview için requestFocus() ve

parçasına

setFocusable(false)

yapmak gerekir;

İlgili konular