Android 为什么垂直方向不垂直渲染图像?
My.xml文件包含以下代码:Android 为什么垂直方向不垂直渲染图像?,android,android-recyclerview,vertical-alignment,Android,Android Recyclerview,Vertical Alignment,My.xml文件包含以下代码: <?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:id="@+
<?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:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:orientation="vertical"
android:id="@+id/image_list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
但是,手机会按如下方式渲染图像:
为什么?您是否正在为RecyclerView设置布局管理器?看这个
setLayoutManager
void setLayoutManager回收视图。LayoutManager布局
设置此RecyclerView将使用的RecyclerView.LayoutManager
与其他适配器支持的视图(如ListView或GridView)不同,RecyclerView允许客户端代码为子视图提供自定义布局安排。这些安排由RecyclerView.LayoutManager控制。必须提供LayoutManager才能使RecyclerView正常工作
我认为您必须与我们共享您的适配器和适配器项布局。