Recyclerview wird nicht im Vollbildmodus angezeigt. Unten ist die Layout-Datei und der Code, den ich geschrieben habe. Nach der Ausführung wird der Inhalt wie im folgenden Bild angezeigt. Die Höhe ist nur der hervorgehobene Teil. Ich möchte, dass der Inhalt im Vollbildmodus angezeigt wird. I verbleibenden Inhalte sind in diesem markierten Bereich, der scrollbar ist. Ich möchte, dass der Inhalt im Vollbildmodus angezeigt wird. Jede Hilfe wäre hilfreich.Recyclerview wird nicht im Vollbild angezeigt
Layout-Datei:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/activity_search"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:clickable="true">
<TextView
android:id="@+id/title"
android:textSize="16dp"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/genre"
android:layout_below="@id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/year"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
Code:
Import android.support.v7.widget.RecyclerView; importieren android.view.LayoutInflater; importieren android.view.View; importieren android.view.ViewGroup; importieren android.widget.TextView; importieren java.util.List;
public class setSearchData erweitert RecyclerView.Adapter {
private List<SearchDisplayContents> moviesList; public class MyViewHolder extends RecyclerView.ViewHolder { public TextView title, year, genre; public MyViewHolder(View view) { super(view); title = (TextView) view.findViewById(R.id.title); genre = (TextView) view.findViewById(R.id.genre); year = (TextView) view.findViewById(R.id.year); } } @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.activity_searchresults, parent, false); return new MyViewHolder(itemView); } @Override public void onBindViewHolder(MyViewHolder holder, int position) { SearchDisplayContents movie = moviesList.get(position); holder.title.setText(movie.getTitle()); holder.genre.setText(movie.getGenre()); holder.year.setText(movie.getYear()); } @Override public int getItemCount() { return moviesList.size(); }
}
Aufruf Funktionscode:
Liste Movielist = new Arraylist <>(); RecyclerView RecyclerView = (RecyclerView) findViewById (R.id.recycler_view);
setSearchData mAdapter = new setSearchData(movieList); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext()); recyclerView.setLayoutManager(mLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.setAdapter(mAdapter); SearchDisplayContents movie = new SearchDisplayContents("Mad Max: Fury Road", "Action & Adventure", "2015"); movieList.add(movie); movie = new SearchDisplayContents("Inside Out", "Animation, Kids & Family", "2015"); movieList.add(movie); mAdapter.notifyDataSetChanged();
zeigen Sie bitte das gesamte Layout Datei – xklakoux
Die Layout-Datei ist abgeschlossen. Bitte überprüfen Sie – Nikhil
Bitte zeigen Sie uns: activity_searchresults.xml – xklakoux