android 旋转屏幕 view的调整,android – 在旋转屏幕后,Recyclerview不会调整大小

我有一个Recyclerview填充了用户插入的项目.我正在实现旋转的功能,因为当我转动设备时,recyclerview显示为空.

调试应用程序,我已经检查旋转之前和之前的完整性,并且ArrayList具有相同的大小.我认为问题是Recyclerview的setNestedScrollingEnabled(false),我设置了这个,因为我不想在rv中显示滚动.

问题是:我处于纵向模式,我添加了3个项目,它在recyclerview中显示我很完美.检查图像:

vzS4C.png

当我将屏幕旋转到横向时,recyclerview的arraylist有3个项目,但高度不会改变,所以它只有一个项目.

342493812ff8d762aa10fb2571d00f3a.png

那么,我如何解决这个问题?

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:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_margin="8dp">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical"

android:padding="8dp">

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" />

android:id="@+id/header_rv_items"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical"

android:visibility="visible">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal"

android:weightSum="4">

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" />

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" />

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" />

android:text="Acciones"

android:textStyle="bold"

android:layout_width="100dp"

android:gravity="right"

android:layout_height="wrap_content"

/>

android:id="@+id/itemsRv"

android:layout_width="match_parent"

android:layout_height="wrap_content"

/>

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" />

我试图将android:layout_height更改为wrap_content和match_parent但没有成功.

非常感谢你!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值