why recycler view max height doesn't work? Also i tried recycler view add inside constraint layout but it doesn't workHow to set RecyclerView Max HeightHow to force TableRow have same heightNested Recycler view height doesn't wrap its contentDisable Tabs in TabLayoutHow can I create a recyclerview child in a recycler parent with auto heightMake RecyclerView height dynamic by wrapping specific number of it's child(not all child)android full width cardview in RecyclerviewRecyclerView items with big empty space v25.2.0Why TextView.getHeight() gives different values?RecycleView conflict with Constraint Layout.(Item view inside recycleview doesn't match_parent)Wrong height in view added Dynamically to a container in Android: weight, Linear and Constraint Layouts

Gibbs free energy in standard state vs. equilibrium

Why do IPv6 unique local addresses have to have a /48 prefix?

Should I install hardwood flooring or cabinets first?

Do Legal Documents Require Signing In Standard Pen Colors?

Diode in opposite direction?

Does the Mind Blank spell prevent the target from being frightened?

How should I respond when I lied about my education and the company finds out through background check?

Proving a function is onto where f(x)=|x|.

THT: What is a squared annular “ring”?

On a tidally locked planet, would time be quantized?

Sampling Theorem and reconstruction

Can I use my Chinese passport to enter China after I acquired another citizenship?

Freedom of speech and where it applies

A social experiment. What is the worst that can happen?

Visiting the UK as unmarried couple

Can someone explain how this makes sense electrically?

Why did the EU agree to delay the Brexit deadline?

Why does Async/Await work properly when the loop is inside the async function and not the other way around?

Have I saved too much for retirement so far?

Proof of Lemma: Every nonzero integer can be written as a product of primes

Do the concepts of IP address and network interface not belong to the same layer?

What linear sensor for a keyboard?

Folder comparison

Greco-Roman egalitarianism



why recycler view max height doesn't work? Also i tried recycler view add inside constraint layout but it doesn't work


How to set RecyclerView Max HeightHow to force TableRow have same heightNested Recycler view height doesn't wrap its contentDisable Tabs in TabLayoutHow can I create a recyclerview child in a recycler parent with auto heightMake RecyclerView height dynamic by wrapping specific number of it's child(not all child)android full width cardview in RecyclerviewRecyclerView items with big empty space v25.2.0Why TextView.getHeight() gives different values?RecycleView conflict with Constraint Layout.(Item view inside recycleview doesn't match_parent)Wrong height in view added Dynamically to a container in Android: weight, Linear and Constraint Layouts













0















I want to max height to recycler view but doesn't work for me. I found some answers but they didn't work for me.

I tried many ways to fix that. but I couldn't found the answer. this is XML code. Anyone can help me to solve that problem



<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="match_parent"
android:layout_height="0dp"
android:maxHeight="100dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>









share|improve this question
























  • Possible duplicate of How to set RecyclerView Max Height

    – user1506104
    Mar 8 at 7:25











  • @user1506104 i know this question already asked in here. But theirs solutions didn't work for me. Thats why again posted this question. Sorry for that

    – Nimantha
    Mar 10 at 13:42
















0















I want to max height to recycler view but doesn't work for me. I found some answers but they didn't work for me.

I tried many ways to fix that. but I couldn't found the answer. this is XML code. Anyone can help me to solve that problem



<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="match_parent"
android:layout_height="0dp"
android:maxHeight="100dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>









share|improve this question
























  • Possible duplicate of How to set RecyclerView Max Height

    – user1506104
    Mar 8 at 7:25











  • @user1506104 i know this question already asked in here. But theirs solutions didn't work for me. Thats why again posted this question. Sorry for that

    – Nimantha
    Mar 10 at 13:42














0












0








0








I want to max height to recycler view but doesn't work for me. I found some answers but they didn't work for me.

I tried many ways to fix that. but I couldn't found the answer. this is XML code. Anyone can help me to solve that problem



<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="match_parent"
android:layout_height="0dp"
android:maxHeight="100dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>









share|improve this question
















I want to max height to recycler view but doesn't work for me. I found some answers but they didn't work for me.

I tried many ways to fix that. but I couldn't found the answer. this is XML code. Anyone can help me to solve that problem



<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="match_parent"
android:layout_height="0dp"
android:maxHeight="100dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>






android android-layout android-recyclerview recyclerview-layout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 7:42









Tamir Abutbul

1,9482822




1,9482822










asked Mar 8 at 6:38









NimanthaNimantha

183




183












  • Possible duplicate of How to set RecyclerView Max Height

    – user1506104
    Mar 8 at 7:25











  • @user1506104 i know this question already asked in here. But theirs solutions didn't work for me. Thats why again posted this question. Sorry for that

    – Nimantha
    Mar 10 at 13:42


















  • Possible duplicate of How to set RecyclerView Max Height

    – user1506104
    Mar 8 at 7:25











  • @user1506104 i know this question already asked in here. But theirs solutions didn't work for me. Thats why again posted this question. Sorry for that

    – Nimantha
    Mar 10 at 13:42

















Possible duplicate of How to set RecyclerView Max Height

– user1506104
Mar 8 at 7:25





Possible duplicate of How to set RecyclerView Max Height

– user1506104
Mar 8 at 7:25













@user1506104 i know this question already asked in here. But theirs solutions didn't work for me. Thats why again posted this question. Sorry for that

– Nimantha
Mar 10 at 13:42






@user1506104 i know this question already asked in here. But theirs solutions didn't work for me. Thats why again posted this question. Sorry for that

– Nimantha
Mar 10 at 13:42













2 Answers
2






active

oldest

votes


















0














Paste this code on your xml activity file. Hope this will work.



 <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="match_parent"
android:layout_height="0dp"
android:maxHeight="100dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />





share|improve this answer























  • thanks, i tried this, but it didn't work. I don't know why....

    – Nimantha
    Mar 10 at 13:17


















0














Your question is not so clear to me but if you want the recyclerView to take all of the screen space you should use this :



 <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>


If you want to limit your recyclerview height I would not recommend using fixed sized in dp - use guideline/barrier to make your recyclerView take only some percent of the screen, for example if you want your view only take 30% of your screen use guidelines with 30% different and constrain your view to them like this:



 <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.4" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.1" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" />

</androidx.constraintlayout.widget.ConstraintLayout>





share|improve this answer























  • i want to add recycler view inside dialog. i used recycler view height as wrap content . when lot of items have dialog height so big. when recycler view height goes more than 400dp (as a example) it should be stopped (i mean height) . then other item to view scroll down. But i used max width in recycler view it didn't work. Also i created a constraint layout and add recycler view inside it and set height to 0dp . it didn't worked

    – Nimantha
    Mar 10 at 13:24












  • This is not a good practice(the fixed sizes), what is wrong with my answer? why not use constraint layout with guidelines like the example I gave?

    – Tamir Abutbul
    Mar 10 at 13:26











  • didn't work bro. ( I used recycler view in dialog) it could be the reason this method didn't work....

    – Nimantha
    Mar 10 at 13:54











  • Ok in that case creat custom dialog with custom layout and in your layout try to do as i sujested in my answer with guidlines.This should work

    – Tamir Abutbul
    Mar 10 at 14:01










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057956%2fwhy-recycler-view-max-height-doesnt-work-also-i-tried-recycler-view-add-inside%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Paste this code on your xml activity file. Hope this will work.



 <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="match_parent"
android:layout_height="0dp"
android:maxHeight="100dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />





share|improve this answer























  • thanks, i tried this, but it didn't work. I don't know why....

    – Nimantha
    Mar 10 at 13:17















0














Paste this code on your xml activity file. Hope this will work.



 <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="match_parent"
android:layout_height="0dp"
android:maxHeight="100dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />





share|improve this answer























  • thanks, i tried this, but it didn't work. I don't know why....

    – Nimantha
    Mar 10 at 13:17













0












0








0







Paste this code on your xml activity file. Hope this will work.



 <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="match_parent"
android:layout_height="0dp"
android:maxHeight="100dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />





share|improve this answer













Paste this code on your xml activity file. Hope this will work.



 <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="match_parent"
android:layout_height="0dp"
android:maxHeight="100dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 8 at 7:19









Aovin MahmudAovin Mahmud

133114




133114












  • thanks, i tried this, but it didn't work. I don't know why....

    – Nimantha
    Mar 10 at 13:17

















  • thanks, i tried this, but it didn't work. I don't know why....

    – Nimantha
    Mar 10 at 13:17
















thanks, i tried this, but it didn't work. I don't know why....

– Nimantha
Mar 10 at 13:17





thanks, i tried this, but it didn't work. I don't know why....

– Nimantha
Mar 10 at 13:17













0














Your question is not so clear to me but if you want the recyclerView to take all of the screen space you should use this :



 <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>


If you want to limit your recyclerview height I would not recommend using fixed sized in dp - use guideline/barrier to make your recyclerView take only some percent of the screen, for example if you want your view only take 30% of your screen use guidelines with 30% different and constrain your view to them like this:



 <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.4" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.1" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" />

</androidx.constraintlayout.widget.ConstraintLayout>





share|improve this answer























  • i want to add recycler view inside dialog. i used recycler view height as wrap content . when lot of items have dialog height so big. when recycler view height goes more than 400dp (as a example) it should be stopped (i mean height) . then other item to view scroll down. But i used max width in recycler view it didn't work. Also i created a constraint layout and add recycler view inside it and set height to 0dp . it didn't worked

    – Nimantha
    Mar 10 at 13:24












  • This is not a good practice(the fixed sizes), what is wrong with my answer? why not use constraint layout with guidelines like the example I gave?

    – Tamir Abutbul
    Mar 10 at 13:26











  • didn't work bro. ( I used recycler view in dialog) it could be the reason this method didn't work....

    – Nimantha
    Mar 10 at 13:54











  • Ok in that case creat custom dialog with custom layout and in your layout try to do as i sujested in my answer with guidlines.This should work

    – Tamir Abutbul
    Mar 10 at 14:01















0














Your question is not so clear to me but if you want the recyclerView to take all of the screen space you should use this :



 <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>


If you want to limit your recyclerview height I would not recommend using fixed sized in dp - use guideline/barrier to make your recyclerView take only some percent of the screen, for example if you want your view only take 30% of your screen use guidelines with 30% different and constrain your view to them like this:



 <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.4" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.1" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" />

</androidx.constraintlayout.widget.ConstraintLayout>





share|improve this answer























  • i want to add recycler view inside dialog. i used recycler view height as wrap content . when lot of items have dialog height so big. when recycler view height goes more than 400dp (as a example) it should be stopped (i mean height) . then other item to view scroll down. But i used max width in recycler view it didn't work. Also i created a constraint layout and add recycler view inside it and set height to 0dp . it didn't worked

    – Nimantha
    Mar 10 at 13:24












  • This is not a good practice(the fixed sizes), what is wrong with my answer? why not use constraint layout with guidelines like the example I gave?

    – Tamir Abutbul
    Mar 10 at 13:26











  • didn't work bro. ( I used recycler view in dialog) it could be the reason this method didn't work....

    – Nimantha
    Mar 10 at 13:54











  • Ok in that case creat custom dialog with custom layout and in your layout try to do as i sujested in my answer with guidlines.This should work

    – Tamir Abutbul
    Mar 10 at 14:01













0












0








0







Your question is not so clear to me but if you want the recyclerView to take all of the screen space you should use this :



 <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>


If you want to limit your recyclerview height I would not recommend using fixed sized in dp - use guideline/barrier to make your recyclerView take only some percent of the screen, for example if you want your view only take 30% of your screen use guidelines with 30% different and constrain your view to them like this:



 <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.4" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.1" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" />

</androidx.constraintlayout.widget.ConstraintLayout>





share|improve this answer













Your question is not so clear to me but if you want the recyclerView to take all of the screen space you should use this :



 <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>


If you want to limit your recyclerview height I would not recommend using fixed sized in dp - use guideline/barrier to make your recyclerView take only some percent of the screen, for example if you want your view only take 30% of your screen use guidelines with 30% different and constrain your view to them like this:



 <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.4" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.1" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewItems"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" />

</androidx.constraintlayout.widget.ConstraintLayout>






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 8 at 7:20









Tamir AbutbulTamir Abutbul

1,9482822




1,9482822












  • i want to add recycler view inside dialog. i used recycler view height as wrap content . when lot of items have dialog height so big. when recycler view height goes more than 400dp (as a example) it should be stopped (i mean height) . then other item to view scroll down. But i used max width in recycler view it didn't work. Also i created a constraint layout and add recycler view inside it and set height to 0dp . it didn't worked

    – Nimantha
    Mar 10 at 13:24












  • This is not a good practice(the fixed sizes), what is wrong with my answer? why not use constraint layout with guidelines like the example I gave?

    – Tamir Abutbul
    Mar 10 at 13:26











  • didn't work bro. ( I used recycler view in dialog) it could be the reason this method didn't work....

    – Nimantha
    Mar 10 at 13:54











  • Ok in that case creat custom dialog with custom layout and in your layout try to do as i sujested in my answer with guidlines.This should work

    – Tamir Abutbul
    Mar 10 at 14:01

















  • i want to add recycler view inside dialog. i used recycler view height as wrap content . when lot of items have dialog height so big. when recycler view height goes more than 400dp (as a example) it should be stopped (i mean height) . then other item to view scroll down. But i used max width in recycler view it didn't work. Also i created a constraint layout and add recycler view inside it and set height to 0dp . it didn't worked

    – Nimantha
    Mar 10 at 13:24












  • This is not a good practice(the fixed sizes), what is wrong with my answer? why not use constraint layout with guidelines like the example I gave?

    – Tamir Abutbul
    Mar 10 at 13:26











  • didn't work bro. ( I used recycler view in dialog) it could be the reason this method didn't work....

    – Nimantha
    Mar 10 at 13:54











  • Ok in that case creat custom dialog with custom layout and in your layout try to do as i sujested in my answer with guidlines.This should work

    – Tamir Abutbul
    Mar 10 at 14:01
















i want to add recycler view inside dialog. i used recycler view height as wrap content . when lot of items have dialog height so big. when recycler view height goes more than 400dp (as a example) it should be stopped (i mean height) . then other item to view scroll down. But i used max width in recycler view it didn't work. Also i created a constraint layout and add recycler view inside it and set height to 0dp . it didn't worked

– Nimantha
Mar 10 at 13:24






i want to add recycler view inside dialog. i used recycler view height as wrap content . when lot of items have dialog height so big. when recycler view height goes more than 400dp (as a example) it should be stopped (i mean height) . then other item to view scroll down. But i used max width in recycler view it didn't work. Also i created a constraint layout and add recycler view inside it and set height to 0dp . it didn't worked

– Nimantha
Mar 10 at 13:24














This is not a good practice(the fixed sizes), what is wrong with my answer? why not use constraint layout with guidelines like the example I gave?

– Tamir Abutbul
Mar 10 at 13:26





This is not a good practice(the fixed sizes), what is wrong with my answer? why not use constraint layout with guidelines like the example I gave?

– Tamir Abutbul
Mar 10 at 13:26













didn't work bro. ( I used recycler view in dialog) it could be the reason this method didn't work....

– Nimantha
Mar 10 at 13:54





didn't work bro. ( I used recycler view in dialog) it could be the reason this method didn't work....

– Nimantha
Mar 10 at 13:54













Ok in that case creat custom dialog with custom layout and in your layout try to do as i sujested in my answer with guidlines.This should work

– Tamir Abutbul
Mar 10 at 14:01





Ok in that case creat custom dialog with custom layout and in your layout try to do as i sujested in my answer with guidlines.This should work

– Tamir Abutbul
Mar 10 at 14:01

















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057956%2fwhy-recycler-view-max-height-doesnt-work-also-i-tried-recycler-view-add-inside%23new-answer', 'question_page');

);

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







Popular posts from this blog

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived