Why does my RecyclerView Layout width looks like its wrap content even though i put it match parent
up vote
-2
down vote
favorite
so I have a recycler view layout that look like the image below. I set the width to match parent and in this layout it is like what I want it to be. So when I call this recycler layout to my home I want the view to be exactly like this.
Recycler Layout
but when I call the recycler view to my home layout and I try to run it why does it becomes like this? its like my width is wrap content. the width isn't full until the right side.
My recycler view when I run the app
here is my recyclerview layout xml code :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
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="90dp"
android:layout_margin="5dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_marginLeft="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:src="@mipmap/ic_launcher"
/>
<TextView
android:id="@+id/textViewTitle"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@+id/imageView"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="20dp"
android:text="Plastik"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
app:layout_constraintTop_toBottomOf="@+id/textViewTitle"
app:layout_constraintLeft_toRightOf="@+id/imageView"
android:text="Non Organik"
android:textSize="16sp"/>
<TextView
android:id="@+id/textViewPrice"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Price"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginRight="5dp"
android:textSize="@dimen/font_medium"
android:textStyle="bold"/>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
And this is my Home Layout xml code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical"
android:theme="@style/HomeTheme"
tools:context=".HomeFragment">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logog40w"
android:layout_width="150dp"
android:layout_height="60dp"
android:src="@drawable/logog4w"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/pohong4w"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentRight="true"
android:src="@drawable/pohong4w"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/user_name"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="Name"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/pohong4w"
app:layout_constraintTop_toTopOf="@+id/logog40w" />
<TextView
android:id="@+id/jemputrutin_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:text="Status Penjemputan Rutin:"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pohong4w" />
<TextView
android:id="@+id/fragment_home_jemputrutin_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="STATUS"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@+id/jemputrutin_status"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/jemputrutin_status" />
<LinearLayout
android:id="@+id/layoutmainfeature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:orientation="horizontal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/jemputrutin_status">
<android.support.v7.widget.CardView
android:id="@+id/jemput_rutin"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp"
>
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_jemputrutin" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Jemput Rutin"
android:textColor="#000000"
android:textSize="12dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/antar_sendiri"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:id="@+id/img_antarsendiri"
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_antarsendiri" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Antar Sendiri"
android:textColor="#000000"
android:textSize="12dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/jemput_sekarang"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_jemputsekarang" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Jemput Sekarang"
android:textColor="#000000"
android:textSize="11dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<TextView
android:id="@+id/recyler_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Harga Per Kg"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/layoutmainfeature" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:nestedScrollingEnabled="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recyler_title" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
android android-studio android-layout
add a comment |
up vote
-2
down vote
favorite
so I have a recycler view layout that look like the image below. I set the width to match parent and in this layout it is like what I want it to be. So when I call this recycler layout to my home I want the view to be exactly like this.
Recycler Layout
but when I call the recycler view to my home layout and I try to run it why does it becomes like this? its like my width is wrap content. the width isn't full until the right side.
My recycler view when I run the app
here is my recyclerview layout xml code :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
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="90dp"
android:layout_margin="5dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_marginLeft="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:src="@mipmap/ic_launcher"
/>
<TextView
android:id="@+id/textViewTitle"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@+id/imageView"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="20dp"
android:text="Plastik"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
app:layout_constraintTop_toBottomOf="@+id/textViewTitle"
app:layout_constraintLeft_toRightOf="@+id/imageView"
android:text="Non Organik"
android:textSize="16sp"/>
<TextView
android:id="@+id/textViewPrice"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Price"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginRight="5dp"
android:textSize="@dimen/font_medium"
android:textStyle="bold"/>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
And this is my Home Layout xml code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical"
android:theme="@style/HomeTheme"
tools:context=".HomeFragment">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logog40w"
android:layout_width="150dp"
android:layout_height="60dp"
android:src="@drawable/logog4w"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/pohong4w"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentRight="true"
android:src="@drawable/pohong4w"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/user_name"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="Name"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/pohong4w"
app:layout_constraintTop_toTopOf="@+id/logog40w" />
<TextView
android:id="@+id/jemputrutin_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:text="Status Penjemputan Rutin:"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pohong4w" />
<TextView
android:id="@+id/fragment_home_jemputrutin_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="STATUS"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@+id/jemputrutin_status"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/jemputrutin_status" />
<LinearLayout
android:id="@+id/layoutmainfeature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:orientation="horizontal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/jemputrutin_status">
<android.support.v7.widget.CardView
android:id="@+id/jemput_rutin"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp"
>
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_jemputrutin" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Jemput Rutin"
android:textColor="#000000"
android:textSize="12dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/antar_sendiri"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:id="@+id/img_antarsendiri"
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_antarsendiri" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Antar Sendiri"
android:textColor="#000000"
android:textSize="12dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/jemput_sekarang"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_jemputsekarang" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Jemput Sekarang"
android:textColor="#000000"
android:textSize="11dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<TextView
android:id="@+id/recyler_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Harga Per Kg"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/layoutmainfeature" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:nestedScrollingEnabled="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recyler_title" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
android android-studio android-layout
1
Have a look at this answer
– Ayush Khare
Nov 9 at 4:27
change RecyclerView's "match_parent" to "0dp"
– sso.techie
Nov 9 at 4:40
FWIW, You can't put aRecyclerView
within aNestedScrollView
going in the same direction and expect it to work - it'll inflate every View in yourRecyclerView
since aNestedScrollView
has an infinite length. You need to make those other views part of your RecyclerView adapter (say, as another view type).
– ianhanniballake
Nov 9 at 5:43
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
so I have a recycler view layout that look like the image below. I set the width to match parent and in this layout it is like what I want it to be. So when I call this recycler layout to my home I want the view to be exactly like this.
Recycler Layout
but when I call the recycler view to my home layout and I try to run it why does it becomes like this? its like my width is wrap content. the width isn't full until the right side.
My recycler view when I run the app
here is my recyclerview layout xml code :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
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="90dp"
android:layout_margin="5dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_marginLeft="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:src="@mipmap/ic_launcher"
/>
<TextView
android:id="@+id/textViewTitle"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@+id/imageView"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="20dp"
android:text="Plastik"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
app:layout_constraintTop_toBottomOf="@+id/textViewTitle"
app:layout_constraintLeft_toRightOf="@+id/imageView"
android:text="Non Organik"
android:textSize="16sp"/>
<TextView
android:id="@+id/textViewPrice"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Price"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginRight="5dp"
android:textSize="@dimen/font_medium"
android:textStyle="bold"/>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
And this is my Home Layout xml code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical"
android:theme="@style/HomeTheme"
tools:context=".HomeFragment">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logog40w"
android:layout_width="150dp"
android:layout_height="60dp"
android:src="@drawable/logog4w"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/pohong4w"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentRight="true"
android:src="@drawable/pohong4w"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/user_name"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="Name"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/pohong4w"
app:layout_constraintTop_toTopOf="@+id/logog40w" />
<TextView
android:id="@+id/jemputrutin_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:text="Status Penjemputan Rutin:"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pohong4w" />
<TextView
android:id="@+id/fragment_home_jemputrutin_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="STATUS"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@+id/jemputrutin_status"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/jemputrutin_status" />
<LinearLayout
android:id="@+id/layoutmainfeature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:orientation="horizontal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/jemputrutin_status">
<android.support.v7.widget.CardView
android:id="@+id/jemput_rutin"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp"
>
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_jemputrutin" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Jemput Rutin"
android:textColor="#000000"
android:textSize="12dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/antar_sendiri"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:id="@+id/img_antarsendiri"
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_antarsendiri" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Antar Sendiri"
android:textColor="#000000"
android:textSize="12dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/jemput_sekarang"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_jemputsekarang" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Jemput Sekarang"
android:textColor="#000000"
android:textSize="11dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<TextView
android:id="@+id/recyler_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Harga Per Kg"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/layoutmainfeature" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:nestedScrollingEnabled="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recyler_title" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
android android-studio android-layout
so I have a recycler view layout that look like the image below. I set the width to match parent and in this layout it is like what I want it to be. So when I call this recycler layout to my home I want the view to be exactly like this.
Recycler Layout
but when I call the recycler view to my home layout and I try to run it why does it becomes like this? its like my width is wrap content. the width isn't full until the right side.
My recycler view when I run the app
here is my recyclerview layout xml code :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
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="90dp"
android:layout_margin="5dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_marginLeft="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:src="@mipmap/ic_launcher"
/>
<TextView
android:id="@+id/textViewTitle"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@+id/imageView"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="20dp"
android:text="Plastik"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
app:layout_constraintTop_toBottomOf="@+id/textViewTitle"
app:layout_constraintLeft_toRightOf="@+id/imageView"
android:text="Non Organik"
android:textSize="16sp"/>
<TextView
android:id="@+id/textViewPrice"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Price"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginRight="5dp"
android:textSize="@dimen/font_medium"
android:textStyle="bold"/>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
And this is my Home Layout xml code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical"
android:theme="@style/HomeTheme"
tools:context=".HomeFragment">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logog40w"
android:layout_width="150dp"
android:layout_height="60dp"
android:src="@drawable/logog4w"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/pohong4w"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentRight="true"
android:src="@drawable/pohong4w"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/user_name"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="Name"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/pohong4w"
app:layout_constraintTop_toTopOf="@+id/logog40w" />
<TextView
android:id="@+id/jemputrutin_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:text="Status Penjemputan Rutin:"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pohong4w" />
<TextView
android:id="@+id/fragment_home_jemputrutin_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="STATUS"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@+id/jemputrutin_status"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/jemputrutin_status" />
<LinearLayout
android:id="@+id/layoutmainfeature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:orientation="horizontal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/jemputrutin_status">
<android.support.v7.widget.CardView
android:id="@+id/jemput_rutin"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp"
>
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_jemputrutin" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Jemput Rutin"
android:textColor="#000000"
android:textSize="12dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/antar_sendiri"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:id="@+id/img_antarsendiri"
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_antarsendiri" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Antar Sendiri"
android:textColor="#000000"
android:textSize="12dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/jemput_sekarang"
android:layout_width="105dp"
android:layout_height="135dp"
android:layout_margin="5dp"
tools:layout_editor_absoluteX="51dp"
tools:layout_editor_absoluteY="51dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:padding="4dp"
android:src="@drawable/g4w_jemputsekarang" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Jemput Sekarang"
android:textColor="#000000"
android:textSize="11dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<TextView
android:id="@+id/recyler_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Harga Per Kg"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/layoutmainfeature" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:nestedScrollingEnabled="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recyler_title" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
android android-studio android-layout
android android-studio android-layout
asked Nov 9 at 4:24
Justin Junias
34
34
1
Have a look at this answer
– Ayush Khare
Nov 9 at 4:27
change RecyclerView's "match_parent" to "0dp"
– sso.techie
Nov 9 at 4:40
FWIW, You can't put aRecyclerView
within aNestedScrollView
going in the same direction and expect it to work - it'll inflate every View in yourRecyclerView
since aNestedScrollView
has an infinite length. You need to make those other views part of your RecyclerView adapter (say, as another view type).
– ianhanniballake
Nov 9 at 5:43
add a comment |
1
Have a look at this answer
– Ayush Khare
Nov 9 at 4:27
change RecyclerView's "match_parent" to "0dp"
– sso.techie
Nov 9 at 4:40
FWIW, You can't put aRecyclerView
within aNestedScrollView
going in the same direction and expect it to work - it'll inflate every View in yourRecyclerView
since aNestedScrollView
has an infinite length. You need to make those other views part of your RecyclerView adapter (say, as another view type).
– ianhanniballake
Nov 9 at 5:43
1
1
Have a look at this answer
– Ayush Khare
Nov 9 at 4:27
Have a look at this answer
– Ayush Khare
Nov 9 at 4:27
change RecyclerView's "match_parent" to "0dp"
– sso.techie
Nov 9 at 4:40
change RecyclerView's "match_parent" to "0dp"
– sso.techie
Nov 9 at 4:40
FWIW, You can't put a
RecyclerView
within a NestedScrollView
going in the same direction and expect it to work - it'll inflate every View in your RecyclerView
since a NestedScrollView
has an infinite length. You need to make those other views part of your RecyclerView adapter (say, as another view type).– ianhanniballake
Nov 9 at 5:43
FWIW, You can't put a
RecyclerView
within a NestedScrollView
going in the same direction and expect it to work - it'll inflate every View in your RecyclerView
since a NestedScrollView
has an infinite length. You need to make those other views part of your RecyclerView adapter (say, as another view type).– ianhanniballake
Nov 9 at 5:43
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
remove these two lines from recycler view and try again
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent
which makes your recycler view part like this
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:nestedScrollingEnabled="true"
app:layout_constraintTop_toBottomOf="@+id/recyler_title" />
stil cannot. do u have any other solution ?
– Justin Junias
Nov 10 at 4:25
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
remove these two lines from recycler view and try again
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent
which makes your recycler view part like this
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:nestedScrollingEnabled="true"
app:layout_constraintTop_toBottomOf="@+id/recyler_title" />
stil cannot. do u have any other solution ?
– Justin Junias
Nov 10 at 4:25
add a comment |
up vote
0
down vote
remove these two lines from recycler view and try again
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent
which makes your recycler view part like this
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:nestedScrollingEnabled="true"
app:layout_constraintTop_toBottomOf="@+id/recyler_title" />
stil cannot. do u have any other solution ?
– Justin Junias
Nov 10 at 4:25
add a comment |
up vote
0
down vote
up vote
0
down vote
remove these two lines from recycler view and try again
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent
which makes your recycler view part like this
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:nestedScrollingEnabled="true"
app:layout_constraintTop_toBottomOf="@+id/recyler_title" />
remove these two lines from recycler view and try again
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent
which makes your recycler view part like this
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:nestedScrollingEnabled="true"
app:layout_constraintTop_toBottomOf="@+id/recyler_title" />
answered Nov 9 at 5:21
Touhidul Islam
424111
424111
stil cannot. do u have any other solution ?
– Justin Junias
Nov 10 at 4:25
add a comment |
stil cannot. do u have any other solution ?
– Justin Junias
Nov 10 at 4:25
stil cannot. do u have any other solution ?
– Justin Junias
Nov 10 at 4:25
stil cannot. do u have any other solution ?
– Justin Junias
Nov 10 at 4:25
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219861%2fwhy-does-my-recyclerview-layout-width-looks-like-its-wrap-content-even-though-i%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Have a look at this answer
– Ayush Khare
Nov 9 at 4:27
change RecyclerView's "match_parent" to "0dp"
– sso.techie
Nov 9 at 4:40
FWIW, You can't put a
RecyclerView
within aNestedScrollView
going in the same direction and expect it to work - it'll inflate every View in yourRecyclerView
since aNestedScrollView
has an infinite length. You need to make those other views part of your RecyclerView adapter (say, as another view type).– ianhanniballake
Nov 9 at 5:43