我有這樣的回收觀點:RecyclerView GridLayoutManager項目match_parent寬度
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
和項目是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="100dp"
android:layout_height="70dp"
android:scaleType="fitCenter"
android:layout_margin="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:linksClickable="true" />
</LinearLayout>
我在代碼中這樣做是爲了有一個2列的網格:
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 2, LinearLayoutManager.VERTICAL,false);
_recycler.setLayoutManager(gridLayoutManager);
我希望每個項目都有可用的「match_parent」空間,事實並非如此!每個項目佔用一半的空間。如何做寬度=「match_parent」的項目和水平滾動的可能性?水平
screen
|------|
ITEM1 - ITEM2
ITEM3 - ITEM4
你想要水平和垂直滾動? – nomag
nop,因爲我想顯示所有沒有垂直滾動的內容。我只是想提供水平滾動顯示項目「隱藏」。 (因爲如果每個項目都顯示在匹配父項中,必須滾動查看其他項) – deveLost
因此,喲要一次顯示一個項目?並水平滾動? –