我不知道下面发生了什么,下面的xmf flie recyclerview的项目与xml中的表格布局类似。当我点击Android系统按钮的最近选项卡时,再次打开我之前离开屏幕的应用程序。
activity_point_table.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/include_toolbar" />
<LinearLayout
android:id="@+id/ll_point_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:background="@color/md_blue_50"
android:gravity="center">
<TextView
android:id="@+id/tv_head_pt_teamname"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Team"
android:textColor="@color/colorBlack"
android:textSize="@dimen/text_size_small" />
<TextView
android:id="@+id/tv_head_pt_match"
style="@style/PTTableHeaderTextView"
android:text="M" />
<TextView
android:id="@+id/tv_head_pt_win"
style="@style/PTTableHeaderTextView"
android:text="W" />
<TextView
android:id="@+id/tv_head_pt_loss"
style="@style/PTTableHeaderTextView"
android:text="L" />
<TextView
android:id="@+id/tv_head_pt_tie"
style="@style/PTTableHeaderTextView"
android:text="T" />
<TextView
android:id="@+id/tv_head_pt_noresult"
style="@style/PTTableHeaderTextView"
android:text="NR" />
<TextView
android:id="@+id/tv_head_pt_pts"
style="@style/PTTableHeaderTextView"
android:text="Pts" />
<TextView
android:id="@+id/tv_head_pt_nrr"
style="@style/PTTableHeaderTextView"
android:text="NRR" />
</TableRow>
</TableLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_point_table"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<TextView
android:id="@+id/tv_no_point_table"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="No Records in Point Table"
android:visibility="invisible" />
</RelativeLayout>
答案 0 :(得分:0)
尝试使用此代码 -
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/include_toolbar" />
<LinearLayout
android:id="@+id/ll_point_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:background="@color/md_blue_50"
android:gravity="center">
<TextView
android:id="@+id/tv_head_pt_teamname"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Team"
android:textColor="@color/colorBlack"
android:textSize="@dimen/text_size_small" />
<TextView
android:id="@+id/tv_head_pt_match"
style="@style/PTTableHeaderTextView"
android:text="M" />
<TextView
android:id="@+id/tv_head_pt_win"
style="@style/PTTableHeaderTextView"
android:text="W" />
<TextView
android:id="@+id/tv_head_pt_loss"
style="@style/PTTableHeaderTextView"
android:text="L" />
<TextView
android:id="@+id/tv_head_pt_tie"
style="@style/PTTableHeaderTextView"
android:text="T" />
<TextView
android:id="@+id/tv_head_pt_noresult"
style="@style/PTTableHeaderTextView"
android:text="NR" />
<TextView
android:id="@+id/tv_head_pt_pts"
style="@style/PTTableHeaderTextView"
android:text="Pts" />
<TextView
android:id="@+id/tv_head_pt_nrr"
style="@style/PTTableHeaderTextView"
android:text="NRR" />
</TableRow>
</TableLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_point_table"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:id="@+id/tv_no_point_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="No Records in Point Table"
android:visibility="invisible" />
</LinearLayout>
答案 1 :(得分:0)
请尝试此代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/include_toolbar" />
<android.support.v4.widget.NestedScrollView
android:id="@+id/ll_point_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:background="@color/md_blue_50"
android:gravity="center">
<TextView
android:id="@+id/tv_head_pt_teamname"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Team"
android:textColor="@color/colorBlack"
android:textSize="@dimen/text_size_small" />
<TextView
android:id="@+id/tv_head_pt_match"
style="@style/PTTableHeaderTextView"
android:text="M" />
<TextView
android:id="@+id/tv_head_pt_win"
style="@style/PTTableHeaderTextView"
android:text="W" />
<TextView
android:id="@+id/tv_head_pt_loss"
style="@style/PTTableHeaderTextView"
android:text="L" />
<TextView
android:id="@+id/tv_head_pt_tie"
style="@style/PTTableHeaderTextView"
android:text="T" />
<TextView
android:id="@+id/tv_head_pt_noresult"
style="@style/PTTableHeaderTextView"
android:text="NR" />
<TextView
android:id="@+id/tv_head_pt_pts"
style="@style/PTTableHeaderTextView"
android:text="Pts" />
<TextView
android:id="@+id/tv_head_pt_nrr"
style="@style/PTTableHeaderTextView"
android:text="NRR" />
</TableRow>
</TableLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_point_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:nestedScrollingEnabled="false" />
</android.support.v4.widget.NestedScrollView>
<TextView
android:id="@+id/tv_no_point_table"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="No Records in Point Table"
android:visibility="invisible" />