我是一位初学者,当我用下面代码编写的时候出现的界面是灰色的,但其实我想实现第一个图片的效果。不知道应该怎么去处理,请求大家指点。
我在build.gradle中添加了implementation 'androidx.recyclerview:recyclerview:1.0.0',
<LinearLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
<com.youth.banner.Banner
android:visibility="gone"
android:id="@+id/fragment_show_banner"
android:layout_width="match_parent"
android:layout_height="200dp"
app:indicator_height="0dp"
app:indicator_width="0dp"
app:indicator_drawable_selected="@drawable/text_gridient_theme"
app:indicator_drawable_unselected="@drawable/circle_write">
</com.youth.banner.Banner>
<RelativeLayout
android:id="@+id/rlt_top"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="@color/mycolor_theme">
<TextView
android:id="@+id/tv_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text=" 返回 "
android:textColor="@color/white"
android:textSize="14sp"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="餐品"
android:textColor="@color/mycolor_ffffff"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text=" "
android:textColor="@color/white"
android:textSize="14sp"
android:visibility="visible" />
</RelativeLayout>
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycleview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
RecycleView 也是 match_parent
应该是第一次引入没有编译过,实际界面显示应该没什么问题,要想在布局中看到recyclerview,可以运行后看看