如何RecyclerView的item宽度设置

item的布局:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.v7.widget.AppCompatButton
        android:layout_height="wrap_content"
        android:text="Text"
        android:id="@+id/at"
        android:layout_width="match_parent"/>

</LinearLayout>

RecyclerView:

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical"/>

运行截图:
图片描述

求解。。。。

还有一个问题为什么AppCompatButton本来是小写问什么运行成大写了。。

阅读 9.5k
2 个回答

大小写问题需要设置下属性android:textAllCaps为false

看下你的onCreateViewHolder

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题