2016-07-31 64 views
0

我有一個具有線性佈局和1個回收站view.The線性佈局的設計包含具有字段名稱爲錶行:課程編號,課程名稱,學分,現狀和回收視圖是顯示行數據。我想設置Horizental滾動滾動Recycler視圖和其他主要xml文件的設計。這是我的主XML文件名content_main.xml如何使用回收站視圖Horizenatl滾動

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginTop="50dp" 
    android:orientation="vertical" 
    android:padding="5dp" 
    tools:context="com.example.soulshunter.revandhv.MainActivity" 
    tools:showIn="@layout/activity_main"> 

    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="left" 
      android:padding="5dp" 
      android:text="Registered Courses" 
      android:textColor="#000000" 
      android:textSize="24sp"> 

     </TextView> 

    </TableRow> 

    <View 
     android:layout_width="fill_parent" 
     android:layout_height="2dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:background="#EEE" 
     android:padding="16dp" /> 

    <TableRow 

     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:background="#00CC99"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="left" 
      android:padding="5dp" 
      android:text="Class" 
      android:textColor="#000000" 
      android:textSize="16sp"> 

     </TextView> 

    </TableRow> 

    <LinearLayout 

     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <TableRow 

      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#ccffff"> 

      <TextView 
       android:layout_width="102dp" 
       android:layout_height="wrap_content" 
       android:gravity="left" 
       android:padding="5dp" 
       android:text="Course Code" 
       android:textColor="#000000" 
       android:textSize="16sp"> 

      </TextView> 

      <TextView 
       android:layout_width="250dp" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="2dp" 
       android:gravity="left" 
       android:text="Course Title" 
       android:textColor="#000000" 
       android:textSize="16sp"> 

      </TextView> 

      <TextView 
       android:layout_width="100dp" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="5dp" 
       android:gravity="left" 
       android:text="Credit Hours" 
       android:textColor="#000000" 
       android:textSize="16sp"> 

      </TextView> 

      <TextView 
       android:layout_width="130dp" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="5dp" 
       android:gravity="left" 
       android:text="Status" 
       android:textColor="#000000" 
       android:textSize="16sp"> 

      </TextView> 

      <TextView 
       android:layout_width="60dp" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="5dp" 
       android:gravity="left" 
       android:text="Action" 
       android:textColor="#000000" 
       android:textSize="16sp"> 

      </TextView> 

     </TableRow> 

    </LinearLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recycler_view" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="5dp"> 

    </android.support.v7.widget.RecyclerView> 

</LinearLayout> 

,我還收到了我的Java文件

mAdapter = new MoviesAdapter(crList); 
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext(),LinearLayoutManager.HORIZONTAL,false); 
    recyclerView.setLayoutManager(mLayoutManager); 
    recyclerView.setItemAnimator(new DefaultItemAnimator()); 
    recyclerView.setAdapter(mAdapter); 

回答

0

設置水平滾動作爲烏拉圭回合佈局父嘗試這樣做。而對於回收者視圖,你可以在回收站視圖佈局管理器中設置滾動屬性。

+0

已經做到了這一點。當我這樣做沒有任何顯示 –

+0

感謝朋友我修復它 –

相關問題