Xamarin Android LinearLayout-一个页面上有2个RecyclerViews的问题
我对v7.widget.RecyclerView有问题。我有一个来自应用程序用户的“帖子”,其中显示了他们之前添加的任何图像,以及任何其他附件(文档、视频等)。可以选择编辑现有帖子 我有一个EditPost xml文件,其中嵌入了一个名为attachment_item的文件。这又嵌入了一个名为EditAttachmentsLayout的xml文件。如果需要,我可以发布前两个文件中的代码,但我认为问题不在这里 EditAttachmentsLayout页面使用2个RecyclerViews;一个用于图像,另一个用于其他文件。代码如下:Xamarin Android LinearLayout-一个页面上有2个RecyclerViews的问题,android,xamarin,android-recyclerview,android-linearlayout,Android,Xamarin,Android Recyclerview,Android Linearlayout,我对v7.widget.RecyclerView有问题。我有一个来自应用程序用户的“帖子”,其中显示了他们之前添加的任何图像,以及任何其他附件(文档、视频等)。可以选择编辑现有帖子 我有一个EditPost xml文件,其中嵌入了一个名为attachment_item的文件。这又嵌入了一个名为EditAttachmentsLayout的xml文件。如果需要,我可以发布前两个文件中的代码,但我认为问题不在这里 EditAttachmentsLayout页面使用2个RecyclerViews;一个用
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/edit_images_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="@+id/edit_attachments_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
如果我点击缩略图上的交叉按钮(或附件本身上的交叉按钮),附件将被删除,然后图像将显示,如下所示:
这就好像回收商在列表中的第一张图像上放置了某种覆盖物。我已经尝试了各种方法来解决这个问题,比如增加间距以迫使两个回收商分开,以及切换到GridView,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:rowCount="4">
<android.support.v7.widget.RecyclerView android:id="@+id/edit_images_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_row="0"
android:scrollbars="none"/>
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_row="1"
android:layout_marginBottom="10dp"/>
<android.support.v7.widget.RecyclerView android:id="@+id/edit_attachments_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_row="2"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
android:scrollbars="none"/>
</GridLayout>
单击十字按钮删除第一个附件后,附件将消失(如预期),图像将再次可见:
很奇怪 建议:
1.尝试将父线性布局高度设置为与父线性布局高度匹配
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"> // **this line here**
<android.support.v7.widget.RecyclerView
android:id="@+id/edit_images_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="@+id/edit_attachments_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
//**这里是这一行**
您是否尝试过查看主线程是否存在问题
RunOnUIThread(()=>{})
-更新适配器
尝试使用以下命令通知回收器适配器更改:
_editImageAdapter.NotifiyDatasetChanged()
_editImageAdapter.NotifiyDatasetChanged()
你是如何加载图像的?如果进入屏幕后没有附件,图像是否仍无法预览?是否可以显示一些代码?如您的RecyclerView适配器?@Merian,如果进入post屏幕且没有附件,则图像显示良好。如果存在附件,则图像将隐藏。如果删除附件,图像将再次显示。奇怪…@Leo Zhu,我已经编辑了这个问题,将创建回收器视图的片段包括在内。LocalFileDeleted方法没有区分删除图片或附件?嗨,不幸的是,这些对我都不起作用。我甚至从linearlayout切换到grid,添加了额外的行和空间,但问题是一样的。通知适配器似乎也没有帮助。我在问题中添加了一些额外的信息,我不认为布局会造成问题吗?从哪里从服务器加载数据,它们是静态映像?
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginRight="20dp"
android:layout_width="@dimen/edit_image_size"
android:layout_height="@dimen/edit_image_size">
<ImageView
android:background="@drawable/image_background"
android:id="@+id/attachment_image"
android:scaleType="fitXY"
android:layout_width="@dimen/edit_image_size"
android:layout_height="@dimen/edit_image_size"/>
<ImageButton
android:background="@drawable/rounded_button_secondary"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:layout_alignTop="@id/attachment_image"
android:layout_alignRight="@id/attachment_image"
android:id="@+id/delete_attachment_button"
android:src="@drawable/icon_of_cross"
android:tint="@color/white"
android:padding="5dp"
android:layout_margin="5dp"
android:layout_width="25dp"
android:layout_height="25dp" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"> // **this line here**
<android.support.v7.widget.RecyclerView
android:id="@+id/edit_images_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="@+id/edit_attachments_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>