0

Ich werde Ansicht von Adapter füllen und wenn iam Daten zu RV füllen dann kann nicht scrollen.Recyclerview mit LinearLayout kann nicht scrollen

Das ist mein RC:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.SwipeRefreshLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/trip_ticket_refresh" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

</android.support.v4.widget.SwipeRefreshLayout> 

RC ist von dieser Ansicht füllen:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    style="@style/TripMyTicketScrollView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentStart="true" 
    android:layout_alignParentTop="true" 
    android:orientation="vertical"> 

    <Button 
     android:id="@+id/my_ticket_port_and_directions" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/grid_14" 
     android:layout_marginEnd="@dimen/grid_2" 
     android:layout_marginLeft="@dimen/grid_2" 
     android:layout_marginRight="@dimen/grid_2" 
     android:layout_marginStart="@dimen/grid_2" 
     android:layout_marginTop="@dimen/grid_1" 
     android:height="@dimen/grid_5" 
     android:background="@color/bg_on_board_button" 
     android:drawableEnd="@drawable/ic_keyboard_arrow_right" 
     android:drawableLeft="@drawable/ic_rudder_black_32dp" 
     android:drawablePadding="6dp" 
     android:drawableRight="@drawable/ic_keyboard_arrow_right" 
     android:drawableStart="@drawable/ic_rudder_black_32dp" 
     android:gravity="center|start" 
     android:padding="@dimen/grid_2" 
     android:text="@string/my_ticket_port_and_direction" 
     android:textColor="@color/text_color_my_trip_button" 
     android:textStyle="bold" /> 

    <include layout="@layout/view_my_trip_time_schedule" /> 

    <include layout="@layout/view_my_trip_passengers_and_cabins" /> 

    <include layout="@layout/view_my_trip_booking_number" /> 


</LinearLayout> 

einige linearen Layouts mit den Tasten und Textview Es gibt in <include layout=...

Und wenn Blick auf der Bildschirmgröße dann normalerweise scroll starten, aber in diesem Fall nicht. Adapter ist leer für jetzt, weil ich dieses Problem lösen muss, werde ich sie fortsetzen.

Können Sie mir helfen? Danke.

aktualisieren Dies ist RC init in Fragment

private void initRecyclerView(){ 
     mAdapter = new MyTicketAdapter(getContext()); 
     RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity()); 
     mRecyclerRv.setLayoutManager(mLayoutManager); 
     mRecyclerRv.setAdapter(mAdapter); 
    } 

Adapter keine Daten für jetzt füllen. Hier Adapter:

public class MyTicketAdapter extends RecyclerView.Adapter<MyTicketAdapter.MyViewHolder> { 

    private static final int BARCODE_IMAGE_WIDTH = 150; 
    private static final int BARCODE_IMAGE_HEIGHT = 40; 

    private Departure mDeparture; 
    private final Context mContext; 

    public class MyViewHolder extends RecyclerView.ViewHolder { 
// 
//  @BindView(R.id.my_ticket_booking_number_barcode_ticket) 
//  ImageView mBarcodeImageView; 
// 
//  @BindView(R.id.my_ticket_booking_number_barcode_booking_number) 
//  TextView mBookingNumberBelowBarcode; 
// 

     public MyViewHolder(View view) { 
      super(view); 
      ButterKnife.bind(this, view); 
     } 

    } 

    /** 
    * Creates a new instance of this class. 
    * 
    * @param context need values from resource. 
    */ 
    public MyTicketAdapter(Context context) { 
     mContext = context; 
    } 

    @Override 
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
     View itemView = LayoutInflater.from(parent.getContext()) 
       .inflate(R.layout.list_item_trip_ticket, parent, false); 
     return new MyViewHolder(itemView); 
    } 

    @Override 
    public void onBindViewHolder(MyTicketAdapter.MyViewHolder holder, int position) { 

     if (mDeparture == null) { 
      return; 
     } 

     TravelMateLogs.MY_TICKET_ADAPTER.i("--------Departure: " + mDeparture.toString()); 

    //  generateBarcode(holder); 
    } 

    @Override 
    public int getItemCount() { 
     // There is only one item. 
     if(mDeparture == null){ 
      return 0; 
     }else { 
      return 1; 
     } 
    } 

    /** 
    * Sets the data to be displayed in the list. 
    * 
    * @param departure The departure to be displayed in the view. Null will clear the list. 
    */ 
    void setData(@Nullable Departure departure) { 
     mDeparture = departure; 
     notifyDataSetChanged(); 
    } 
} 
+0

Nur für einen Testfall kann u Android ändern: layout_height = "match_parent "to android: layout_height =" wrap_content "für das LinearLayout des recyclerview-Elements und versuchen Sie es mit – Raghavendra

+0

Nichts ist passiert –

Antwort

0

Lösung:

Ich hatte alle Teil Linearlayout zu wickeln:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    style="@style/TripMyTicketScrollView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentStart="true" 
    android:layout_alignParentTop="true" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/bg_trip_tab_view" 
     android:orientation="vertical" 
     android:paddingBottom="@dimen/grid_14"> 


     <include layout="@layout/view_my_trip_time_schedule" /> 

     <include layout="@layout/view_my_trip_passengers_and_cabins" /> 

     <include layout="@layout/view_my_trip_booking_number" /> 

    </LinearLayout> 
</LinearLayout> 

Jetzt ist es Arbeit ...

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

Wenn Wrap ist, recyclerview ist nicht sichtbar. Bitte auch die Recyclerview-Initialisierung posten.

Verwandte Themen