我想让它们(项目下的项目)我是(2项2项下)我怎么能改变它们我想显示正常的项目?
card.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="wrap_content"
android:layout_height="144dp"
android:layout_gravity="center"
android:elevation="3dp"
card_view:cardUseCompatPadding="true"
card_view:cardElevation="4dp"
card_view:cardCornerRadius="1dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="120dp">
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/txt_idArticle1"
android:textStyle="normal|bold" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_idArticle1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="11dp"
android:id="@+id/txt_reference1"
android:textStyle="normal|bold" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/txt_des1"
android:textStyle="normal|bold" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_des1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="16dp"
android:id="@+id/txt_prix1"
android:textStyle="normal|bold" />
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/txt_idArticle1"
android:layout_toEndOf="@+id/txt_idArticle1"
android:layout_marginLeft="21dp"
android:layout_marginStart="21dp"
android:id="@+id/txt_idArticle" />
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/txt_reference1"
android:layout_alignLeft="@+id/txt_idArticle"
android:layout_alignStart="@+id/txt_idArticle"
android:id="@+id/txt_reference" />
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignLeft="@+id/txt_reference"
android:layout_alignStart="@+id/txt_reference"
android:id="@+id/txt_des" />
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txt_prix"
android:layout_alignBaseline="@+id/txt_prix1"
android:layout_alignBottom="@+id/txt_prix1"
android:layout_alignLeft="@+id/txt_des"
android:layout_alignStart="@+id/txt_des" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
recherche_article.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_recherche_article"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.bacha.pfe.RechercheArticle">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardUseCompatPadding="true"
card_view:cardElevation="5dp"
card_view:cardCornerRadius="5dp"
android:scrollbars="vertical"
android:layout_marginTop="6dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
答案 0 :(得分:0)
旧代码:
gridLayoutManager = new GridLayoutManager(this,2);
新代码:
gridLayoutManager = new GridLayoutManager(this,1);
我只是更改了所有
的GridLayoutManager大小