मेरे पास उपयोगकर्ता द्वारा डाली गई वस्तुओं के साथ एक पुनर्नवीनीकरण है। मैं रोटेशन की funtionality लागू कर रहा हूँ, क्योंकि जब मैं डिवाइस बारी, recyclerview खाली दिखाता है।पुनर्नवीनीकरण स्क्रीन घुमाए जाने के बाद आकार बदलता नहीं है
ऐप डिबग करना, मैं पहले से ही घुमाव के पहले और पहले अखंडता की जांच करता हूं और ऐरेलिस्ट के समान आकार होता है। मुझे लगता है कि समस्या Recyclerview के setNestedScrollingEnabled(false)
है, मैंने इसे सेट किया क्योंकि मैं आरवी में स्क्रॉल नहीं दिखाना चाहता हूं।
समस्या है: मैं पोर्ट्रेट मोड में हूं और मैं 3 आइटम जोड़ता हूं, यह मुझे रीसाइक्लिंग व्यू में सही दिखाता है। छवि की जाँच करें:
जब मैं परिदृश्य के लिए स्क्रीन बारी बारी से, recyclerview की ArrayList 3 आइटम नहीं हैं लेकिन ऊंचाई इतनी नहीं बदलता है यह केवल एक आइटम के लिए apppears।
तो, कैसे मैं इस को हल?
Recyclerview:
itemsRv = (RecyclerView) findViewById(R.id.itemsRv);
itemsRv.setNestedScrollingEnabled(false);
itemAutoCompleteAdapter = new ItemAutoCompleteAdapter(this);
if(items ==null){
items = new ArrayList<>();
}
itemsAdapter = new ItemsRowAdapter(this, items, new ItemsRowAdapter.itemsRowListener() {
@Override
public void editarItemOnClick(View v, int position) {
editar_item(items.get(position), position);
}
@Override
public void eliminarItemOnClick(View v, final int position) {
}
});
itemsRv.setHasFixedSize(true);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
itemsRv.setLayoutManager(mLayoutManager);
itemsRv.setAdapter(itemsAdapter);
लेआउट:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginBottom="4dp"
android:text="Items"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/header_rv_items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4">
<TextView
android:id="@+id/textView3"
android:layout_width="@dimen/widthColumnTable"
android:layout_height="wrap_content"
android:layout_weight="2.8"
android:textStyle="bold"
android:text="Descripción" />
<TextView
android:id="@+id/textView5"
android:layout_width="@dimen/widthColumnTable"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="right"
android:textStyle="bold"
android:text="Cantidad" />
<TextView
android:id="@+id/textView8"
android:layout_width="@dimen/widthColumnTable"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:gravity="right"
android:textStyle="bold"
android:text="Precio total" />
<TextView
android:text="Acciones"
android:textStyle="bold"
android:layout_width="100dp"
android:gravity="right"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView <----- HERE IT IS
android:id="@+id/itemsRv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/btn_01_agregar_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginTop="20dp"
android:background="@drawable/border_spinner"
android:gravity="left|center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="Ingrese el código o descrpción del producto"
android:textAllCaps="false"
android:textColor="#616161" />
</LinearLayout>
</android.support.v7.widget.CardView>
मैं सफलता के बिना wrap_content
और match_parent
को android:layout_height
बदलने के लिए कोशिश की है।
बहुत बहुत धन्यवाद!