前言:
之前做了一个文件管理器的app,那么列表中只有名字....实在太简陋了,所以我打算做一个比较好看一点的列表。
效果图:
可能对于专业的你来说,还是比较简陋。这次列表中,除了文件名,我还添加了图标,文件大小,文件权限还有修改日期。
首先这是一个RecyclerView..然后先上代码,这个RecyclerView的部分代码
<?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:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/myFileImage"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="5dp"
app:srcCompat="@mipmap/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/myFileName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:singleLine="true"
android:ellipsize="start"
android:textSize="25sp"
android:layout_gravity="center"
android:text="TextView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/fileSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="大小" />
<TextView
android:id="@+id/filePower"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="权限" />
<TextView
android:id="@+id/fileDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="创建日期" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
这个是列表每个项目的样子,来张截图
<