我刚刚开始使用Recycler视图,但我似乎无法找到任何方法将页眉或页脚设置为回收器视图注意我正在使用LinearLayouManager.
有没有办法将标题添加到Recycler视图?
解决了
我使用这种模式/sf/answers/1860133691/
我有一个包含2个cardview的片段,其中包含多个控件.
在第二张cardview 下面我有一个recyclerview,这很完美.
问题是recyclerview从屏幕底部开始,滚动recylcerview非常小.
以前使用过listview,这使我保持适合你的内容,从而立即滚动屏幕,但recylclerview不能.
当我在recyclerview中滚动时,如何进行控制,就像视差效果一样?
编辑:更清楚,想象一个片段中的2张卡片,这些占据屏幕的80%,其中上面是一个带有100个项目列表的回收者视图,但是卷轴是如此微小......列表视图让我适应"内容"并立即滚动整个屏幕.
这是我的XML布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/svScroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<include
android:id="@+id/cvCampos1"
layout="@layout/ctlcabeceralibreta" />
<include
android:id="@+id/cvCampos2"
layout="@layout/ctlcabeceralibreta2" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rvRegistros"
android:layout_width="fill_parent"
android:layout_height="1000dp"
android:layout_below="@id/cvCampos2"
android:scrollbars="vertical" />
</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
这是截图:

android android-appcompat android-layout android-cardview android-recyclerview
我正在尝试实现下面的图像.我的第一个想法是让网格布局上方的所有内容都是网格的第一行,并使用SpanSizeLookup将跨度大小设置为RecyclerView中的列数,但这感觉就像会给我带来很多问题.
我一直在阅读将RecyclerView放在NestedScrollView中,人们说它有效,但我似乎无法让它正常工作.滚动似乎不正常,我不能让网格甚至在没有设置minHeight的情况下显示,但是它看起来很糟糕.
还有其他选择我不考虑或者是我应该走的方向之一吗?
再会,
我有这个屏幕,我想在其中显示投标的赢家和输家。
它需要看起来像这样:
TextView - Winners
Name and bid amount
Name and bid amount
Name and bid amount
--------------------
Textview - Losers
Name and bid amount
Name and bid amount
Name and bid amount
Name and bid amount
Run Code Online (Sandbox Code Playgroud)
来自网络服务的响应如下:
{
"winningBids": [
{
"amount": 500,
"quantity": 1,
"name": "Craig",
"status": "WINNING"
}
],
"losingBids": [
{
"amount": 461,
"quantity": 1,
"name": "Bob",
"status": "LOSE"
},
{
"amount": 460,
"quantity": 1,
"name": "James",
"status": "LOSE"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想过在同一个屏幕上有 2 个 …
为电视应用创建了双向可滚动gridlayout
从布局文件查看结构
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#021257"
android:orientation="vertical">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rvThumbnail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#021257"
android:orientation="vertical"/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
所以我使用了gridlayoutmanager(方向垂直),spancount为49(24hrs*2)+1,用于显示列的图像.的第一行是显示时间轴分成半小时时隙,第一列是显示信道,每个信道将具有下不同时隙运行其自己的程序.现在我已经实现了两种方式滚动网格布局,现在我还有两件事要做.
1)当水平滚动时,通道列(第一列)也会滚动并因此被隐藏(它必须垂直滚动,因为可以有20多个通道).现在我需要使这个列静态wen水平滚动,其他列必须正常滚动
2)当垂直滚动时,时间轴行(第一行)也会滚动并因此被隐藏(它必须水平滚动,因为行必须显示24小时).现在我需要使这行静态wen垂直滚动,其他行必须正常滚动.
这有可能实现吗?我感谢您的帮助
点击一个按钮,我试图膨胀的EditText上方RecyclerView。但不是将 EditText 添加到布局的顶部,从而将 RecyclerView 向下推,而是将它简单地放置在 RecyclerView 的顶部,像这样覆盖它:

您可以看到“新文本”覆盖了 RecyclerView 的第一项。如何让它在 RecyclerView 上方膨胀,并将 RecyclerView 向下推,以容纳新添加的 EditText?
这是我将 EditText 添加到的 FrameLayout 的 XML:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_my_frame_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
<com.melnykov.fab.FloatingActionButton
android:id="@+id/button_floating_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@drawable/ic_action_new"
fab:fab_colorNormal="@color/primary_dark"
fab:fab_colorPressed="@color/primary" />
Run Code Online (Sandbox Code Playgroud)
这是我的 FloatingActionButton 的 onClick 方法,我希望在 RecyclerView 上方添加 EditText:
public void onClick(View v) {
ViewGroup parent = (ViewGroup) rootView.findViewById(R.id.fragment_my_frame_layout);
View view = LayoutInflater.from(getActivity()).inflate(R.layout.add_keyword_edittext, parent, true);
}
Run Code Online (Sandbox Code Playgroud)
这是我添加的 EditText 的 XML:
<?xml version="1.0" encoding="utf-8"?> …Run Code Online (Sandbox Code Playgroud) android layout-inflater android-recyclerview android-framelayout
我正在使用recyclerview来显示和播放用户的视频.但是,当我滚动循环播放器视图时,我会看到我的第一个视图,其中我的视频被回收,因此其他用户无法看到它.有没有办法可以确保第一个视图不被回收,所以我不必担心每次滚动列表时我的视频视图都会重置回来?
这是我的代码:在我的片段......
<android.support.v7.widget.RecyclerView
android:id="@+id/videoList"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="invisible"
app:layout_constraintBottom_toTopOf="@+id/myButtonContainer"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/myoldContainer">
Run Code Online (Sandbox Code Playgroud)
...
和相应的适配器......
public class GroupAdapter extends RecyclerView.Adapter<GroupAdapter.myViewHolder> {
private CopyOnWriteArrayList<Person> persons;
private Context mContext;
public GroupAdapter(@NonNull final CopyOnWriteArrayList<Person> persons , Context context) {
this.persons = persons;
this.mContext= context;
for (Person person : this.persons) {
//get names
}
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final View layout = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_person, parent, false);
final MyViewHolder viewHolder = new MyViewHolder(layout);
return viewHolder;
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) …Run Code Online (Sandbox Code Playgroud) android android-layout android-fragments android-videoview android-recyclerview
我想设置一个标题为staggardGridLayoutManeger我有这个网址的代码 https://github.com/willblaschko/header-footer-recycler-view.此代码包含所有类型的布局的页眉和页脚.任何人都可以帮助设置适配器只为staggardGridLayout这是样本的代码形式
enter code here
public class RecyclerViewHeaderFooterAdapter extends RecyclerView.Adapter {
public static final int TYPE_MANAGER_OTHER = 0;
public static final int TYPE_MANAGER_LINEAR = 1;
public static final int TYPE_MANAGER_GRID = 2;
public static final int TYPE_MANAGER_STAGGERED_GRID = 3;
public static final int TYPE_HEADER = 7898;
public static final int TYPE_FOOTER = 7899;
private List<View> mHeaders = new ArrayList<>();
private List<View> mFooters = new ArrayList<>();
private int mManagerType;
private RecyclerView.LayoutManager mManager;
private IRecyclerViewIntermediary mIntermediary;
public RecyclerViewHeaderFooterAdapter(RecyclerView.LayoutManager manager, IRecyclerViewIntermediary intermediary){ …Run Code Online (Sandbox Code Playgroud) 我有以下布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.mkallingal.freakingnav.CardsListFragment">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/darktext"
android:layout_marginBottom="6dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Cards Listing" />
<android.support.v7.widget.RecyclerView android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/rvCardsList"
android:scrollbars="vertical" tools:listitem="@layout/recycler_item_layout">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
问题是 TextView 总是粘在顶部,而 RecyclerView 占用屏幕上的剩余空间。我可以水平滚动 recyclerview,但 TextView 只是停留在那里。我如何解决这个问题?
我正在使用recyclelerview和staggeredGridLayoutManager.我想要做的是在第一行显示一个标题项.然后我想在下面每行显示2个项目.但我无法这样做.
这是我用过的代码.
recyclerView = (RecyclerView)findViewById(R.id.recycler);
staggeredGridLayoutManager = new StaggeredGridLayoutManager(1,1);
recyclerView.setLayoutManager(staggeredGridLayoutManager);
Run Code Online (Sandbox Code Playgroud)
这些都是结果
帮助我.谢谢