傢伙,我有一個簡單的recyclerviewRecyclerview高度是一樣大的屏幕
<RelativeLayout 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:orientation="vertical"
android:weightSum="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/realm_recycler_view"
android:background="@null"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</RelativeLayout>
但它不顯示是否正確。我期待它顯示像一個正常的列表視圖(高度明智),但不知何故,每個回收查看項目需要整個屏幕。 (因此其大如屏幕)
我曾經嘗試都WRAP_CONTENT和match_parent沒有成功..
如何解決這個有什麼建議?
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main_activity_fragment_two, container, false);
recyclerView = (RecyclerView) rootView.findViewById(R.id.realm_recycler_view);
setupRecyclerView();
return rootView;
}
public void setupRecyclerView() {
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(new gradeRealmAdapter(this, realm.where(Grade.class).findAllAsync()));
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
recyclerView.setNestedScrollingEnabled(false);
}
我不認爲你需要'weightSum =「1」'屬性規範的佈局。你可以嘗試沒有它? – milosmns
沒有幫助@milosmns – Reshad