Android 为什么设备上不显示RecyclerView,但在Layout Inspector中可见?

Android 为什么设备上不显示RecyclerView,但在Layout Inspector中可见?,android,android-recyclerview,layout-inspector,Android,Android Recyclerview,Layout Inspector,我想在我的应用程序上显示一张带有图片的幻灯片,我实现了一个小小的水平循环视图 在我向recyclerview添加了一张照片后,左边的屏幕是运行时屏幕截图,右边的屏幕显示在Layout Inspector中 回收视图的原始位置在CardView中,我将其移出,因为它也没有显示在那里。你知道为什么吗 一些代码: activity.xml <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

我想在我的应用程序上显示一张带有图片的幻灯片,我实现了一个小小的水平循环视图

在我向recyclerview添加了一张照片后,左边的屏幕是运行时屏幕截图,右边的屏幕显示在Layout Inspector中

回收视图的原始位置在CardView中,我将其移出,因为它也没有显示在那里。你知道为什么吗

一些代码:

activity.xml

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".TheActivity">

    <fragment
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="TheFragment"
        android:tag="@string/the_tag"
        tools:layout="@layout/the_layout"
        android:id="@+id/the_id"/>
</FrameLayout>
<layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:bind="http://schemas.android.com/apk/res-auto"
    tools:context="TheActivity" >

<data>
    <!-- Some vars -->
</data>

<LinearLayout android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView  android:visibility="visible"
        android:id="@+id/frag_add_property_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:orientation="vertical"
            android:focusableInTouchMode="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">               
            <android.support.v7.widget.RecyclerView android:id="@+id/the_rv"
                android:layout_width="match_parent"
                android:layout_height="150dp"
     app:layoutManager="android.support.v7.widget.LinearLayoutManager"                    
                android:orientation="horizontal"
  android:layout_marginBottom="@dimen/activity_half_vertical_margin"/>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

fragment.xml

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".TheActivity">

    <fragment
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="TheFragment"
        android:tag="@string/the_tag"
        tools:layout="@layout/the_layout"
        android:id="@+id/the_id"/>
</FrameLayout>
<layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:bind="http://schemas.android.com/apk/res-auto"
    tools:context="TheActivity" >

<data>
    <!-- Some vars -->
</data>

<LinearLayout android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView  android:visibility="visible"
        android:id="@+id/frag_add_property_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:orientation="vertical"
            android:focusableInTouchMode="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">               
            <android.support.v7.widget.RecyclerView android:id="@+id/the_rv"
                android:layout_width="match_parent"
                android:layout_height="150dp"
     app:layoutManager="android.support.v7.widget.LinearLayoutManager"                    
                android:orientation="horizontal"
  android:layout_marginBottom="@dimen/activity_half_vertical_margin"/>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

public类片段扩展BaseFragment实现视图{
私有图片文件适配器;
@BindView(R.id.rv\添加\属性\图片)
RecyclerView imageRv;
@凌驾
创建视图时的公共视图(LayoutFlater充气机、@Nullable ViewGroup容器、@Nullable Bundle savedInstanceState){
bind=DataBindingUtil.充气(充气器,getLayout(),容器,false);
unbinder=ButterKnife.bind(这个,bind.getRoot());
Drawable dividerDrawable=ContextCompat.getDrawable(getActivity(),R.Drawable.rv\u item\u hor\u divider);
imageRv.addItemDecoration(新CustomItemDecoration(可分割绘制));
返回bind.getRoot();
}
类PictureFileAdapter扩展了RecyclerView.Adapter{
语境;
公共ArrayList文件;
公共ArrayList getFiles(){
归还文件;
}
AddPropertyView视图;
PictureFileAdapter(AddPropertyView视图,上下文){
this.context=上下文;
this.files=new ArrayList();
this.view=视图;
}
@凌驾
公共属性类型CreateViewHolder onCreateViewHolder(视图组父级,int-viewType){
LayoutFlater充气机=LayoutFlater.from(上下文);
视图v=充气机。充气(R.layout.item\u rv\u add\u属性,父项,false);
返回新的AddPropertyFragment.PropertyPictureViewHolder(v);
}
@凌驾
BindViewHolder上的公共无效(PropertyPictureViewHolder,int位置){
holder.textView.setText(files.get(position.getAbsolutePath());
毕加索。与(上下文)
.load(文件.get(位置))
.插入(支架.图像视图);
}
@凌驾
public int getItemCount(){
返回文件.size();
}
void addFile(文件文件){
this.files.add(文件);
notifyDataSetChanged();
}
}
类PropertyPictureViewHolder扩展了RecyclerView.ViewHolder{
私有Uri;
@BindView(R.id.item_rv_add_prop_image)图像视图图像视图;
@BindView(R.id.item\u rv\u add\u prop\u image\u src)文本视图文本视图;
PropertyPictureViewHolder(视图){
超级(视图);
ButterKnife.bind(这个,视图);
view.setOnClickListener((v)->{
//一些逻辑
});
}
}

}您能提供您的代码吗

它没有出现的原因有多种可能

  • 它没有布局管理器
  • 它没有适配器
  • 适配器.getCount()返回0

  • 你能提供你的代码吗

    它没有出现的原因有多种可能

  • 它没有布局管理器
  • 它没有适配器
  • 适配器.getCount()返回0

  • 结果是,即使对毕加索来说,位图也太大了。在显示位图之前缩小它的尺寸确实很神奇。

    结果是,位图太大了,即使对于毕加索来说也是如此。在显示位图之前缩小位图的尺寸确实很神奇。

    1。确实有。2.确实有。3.计数>0。我更新了问题。请再读一遍,看看上面的代码。您在哪里创建并应用了适配器?在
    onViewCreated()
    中,您是否解决了该问题?我看不到正在创建适配器的代码。您的onCreateView只是膨胀视图,并创建项目装饰。而且我也没有看到
    unbind
    data type.Lol。不,你的回答没有帮助。确实有。2.确实有。3.计数>0。我更新了问题。请再读一遍,看看上面的代码。您在哪里创建并应用了适配器?在
    onViewCreated()
    中,您是否解决了该问题?我看不到正在创建适配器的代码。您的onCreateView只是膨胀视图,并创建项目装饰。而且我也没有看到
    unbind
    data type.Lol。不。你的答案没有帮助。你能分享你的代码吗?你能分享你的代码吗?