How to set a view's height match parent in ConstraintLayout?
I am creating a layout.I want to set my custom toolbar(Which is another layout) to the top
of layout and the FrameLayout just below the toolbar. But the FrameLayout should get rest of the layout's height(match_parent).How to achieve this using constraint layout ?
Thank you in advance.
add a comment |
I am creating a layout.I want to set my custom toolbar(Which is another layout) to the top
of layout and the FrameLayout just below the toolbar. But the FrameLayout should get rest of the layout's height(match_parent).How to achieve this using constraint layout ?
Thank you in advance.
Possible duplicate of Set width to match constraints in ConstraintLayout
– Mr. Roshan
Nov 14 '18 at 11:23
Please see my solution and check if it is exactly how you need.
– Ümañg ßürmån
Nov 15 '18 at 5:11
add a comment |
I am creating a layout.I want to set my custom toolbar(Which is another layout) to the top
of layout and the FrameLayout just below the toolbar. But the FrameLayout should get rest of the layout's height(match_parent).How to achieve this using constraint layout ?
Thank you in advance.
I am creating a layout.I want to set my custom toolbar(Which is another layout) to the top
of layout and the FrameLayout just below the toolbar. But the FrameLayout should get rest of the layout's height(match_parent).How to achieve this using constraint layout ?
Thank you in advance.
edited Nov 15 '18 at 5:13
Ümañg ßürmån
3,20831030
3,20831030
asked Nov 14 '18 at 11:20
Yogesh KatkarYogesh Katkar
477
477
Possible duplicate of Set width to match constraints in ConstraintLayout
– Mr. Roshan
Nov 14 '18 at 11:23
Please see my solution and check if it is exactly how you need.
– Ümañg ßürmån
Nov 15 '18 at 5:11
add a comment |
Possible duplicate of Set width to match constraints in ConstraintLayout
– Mr. Roshan
Nov 14 '18 at 11:23
Please see my solution and check if it is exactly how you need.
– Ümañg ßürmån
Nov 15 '18 at 5:11
Possible duplicate of Set width to match constraints in ConstraintLayout
– Mr. Roshan
Nov 14 '18 at 11:23
Possible duplicate of Set width to match constraints in ConstraintLayout
– Mr. Roshan
Nov 14 '18 at 11:23
Please see my solution and check if it is exactly how you need.
– Ümañg ßürmån
Nov 15 '18 at 5:11
Please see my solution and check if it is exactly how you need.
– Ümañg ßürmån
Nov 15 '18 at 5:11
add a comment |
4 Answers
4
active
oldest
votes
Solution: I'm assuming that you have your toolbar as another xml file, something like this:
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dp"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
then using ConstraintLayout use it with FrameLayout like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
</android.support.constraint.ConstraintLayout>
Hope this helps. Please comment if you have any issues with it.
add a comment |
Use 0dp that is match_contraint in ConstraintLayout.
Like android:layout_height="0dp"
Thanks for the answer @Pankaj. I already did it, but did not help.
– Yogesh Katkar
Nov 14 '18 at 11:22
Then better to add your layout code.
– Pankaj Kumar
Nov 14 '18 at 11:23
Not onlyandroid:layout_height="0dp"but addingapp:layout_constraintBottom_toBottomOf="parent"this line solved my problem.
– Yogesh Katkar
Nov 14 '18 at 11:29
@YogeshKatkar Yes that will required as you are using ConstraintLayout you need to set constraints. I thought you would be doing all these things, only height is not working.
– Pankaj Kumar
Nov 14 '18 at 11:30
I used left,right and top only bottom constraint was missing.
– Yogesh Katkar
Nov 14 '18 at 11:31
add a comment |
Note, that unlike other viewgroups in android, constraintlayout should have circular dependencies between the child views. Herewith, you should use 0dp instead of 'match_parent' width and constraints for each side of the child view.
<android.support.constraint.ConstraintLayout
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="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
</android.support.constraint.ConstraintLayout>
add a comment |
give the toolbar an id ,
and in your frame layout set the width and height to 0dp add the constraints like in this code..
<android.support.constraint.ConstraintLayout
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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Main2Activity">
<Toolbar
android:id="@+id/toolbar"
app:layout_constraintTop_toTopOf="parent"
android:background="#ab1010"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Toolbar>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="#f1f1df"
>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
add a comment |
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
});
}
});
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%2f53299024%2fhow-to-set-a-views-height-match-parent-in-constraintlayout%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Solution: I'm assuming that you have your toolbar as another xml file, something like this:
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dp"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
then using ConstraintLayout use it with FrameLayout like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
</android.support.constraint.ConstraintLayout>
Hope this helps. Please comment if you have any issues with it.
add a comment |
Solution: I'm assuming that you have your toolbar as another xml file, something like this:
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dp"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
then using ConstraintLayout use it with FrameLayout like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
</android.support.constraint.ConstraintLayout>
Hope this helps. Please comment if you have any issues with it.
add a comment |
Solution: I'm assuming that you have your toolbar as another xml file, something like this:
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dp"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
then using ConstraintLayout use it with FrameLayout like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
</android.support.constraint.ConstraintLayout>
Hope this helps. Please comment if you have any issues with it.
Solution: I'm assuming that you have your toolbar as another xml file, something like this:
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dp"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
then using ConstraintLayout use it with FrameLayout like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
</android.support.constraint.ConstraintLayout>
Hope this helps. Please comment if you have any issues with it.
answered Nov 15 '18 at 5:10
Ümañg ßürmånÜmañg ßürmån
3,20831030
3,20831030
add a comment |
add a comment |
Use 0dp that is match_contraint in ConstraintLayout.
Like android:layout_height="0dp"
Thanks for the answer @Pankaj. I already did it, but did not help.
– Yogesh Katkar
Nov 14 '18 at 11:22
Then better to add your layout code.
– Pankaj Kumar
Nov 14 '18 at 11:23
Not onlyandroid:layout_height="0dp"but addingapp:layout_constraintBottom_toBottomOf="parent"this line solved my problem.
– Yogesh Katkar
Nov 14 '18 at 11:29
@YogeshKatkar Yes that will required as you are using ConstraintLayout you need to set constraints. I thought you would be doing all these things, only height is not working.
– Pankaj Kumar
Nov 14 '18 at 11:30
I used left,right and top only bottom constraint was missing.
– Yogesh Katkar
Nov 14 '18 at 11:31
add a comment |
Use 0dp that is match_contraint in ConstraintLayout.
Like android:layout_height="0dp"
Thanks for the answer @Pankaj. I already did it, but did not help.
– Yogesh Katkar
Nov 14 '18 at 11:22
Then better to add your layout code.
– Pankaj Kumar
Nov 14 '18 at 11:23
Not onlyandroid:layout_height="0dp"but addingapp:layout_constraintBottom_toBottomOf="parent"this line solved my problem.
– Yogesh Katkar
Nov 14 '18 at 11:29
@YogeshKatkar Yes that will required as you are using ConstraintLayout you need to set constraints. I thought you would be doing all these things, only height is not working.
– Pankaj Kumar
Nov 14 '18 at 11:30
I used left,right and top only bottom constraint was missing.
– Yogesh Katkar
Nov 14 '18 at 11:31
add a comment |
Use 0dp that is match_contraint in ConstraintLayout.
Like android:layout_height="0dp"
Use 0dp that is match_contraint in ConstraintLayout.
Like android:layout_height="0dp"
edited Nov 14 '18 at 11:23
answered Nov 14 '18 at 11:20
Pankaj KumarPankaj Kumar
63.9k22132159
63.9k22132159
Thanks for the answer @Pankaj. I already did it, but did not help.
– Yogesh Katkar
Nov 14 '18 at 11:22
Then better to add your layout code.
– Pankaj Kumar
Nov 14 '18 at 11:23
Not onlyandroid:layout_height="0dp"but addingapp:layout_constraintBottom_toBottomOf="parent"this line solved my problem.
– Yogesh Katkar
Nov 14 '18 at 11:29
@YogeshKatkar Yes that will required as you are using ConstraintLayout you need to set constraints. I thought you would be doing all these things, only height is not working.
– Pankaj Kumar
Nov 14 '18 at 11:30
I used left,right and top only bottom constraint was missing.
– Yogesh Katkar
Nov 14 '18 at 11:31
add a comment |
Thanks for the answer @Pankaj. I already did it, but did not help.
– Yogesh Katkar
Nov 14 '18 at 11:22
Then better to add your layout code.
– Pankaj Kumar
Nov 14 '18 at 11:23
Not onlyandroid:layout_height="0dp"but addingapp:layout_constraintBottom_toBottomOf="parent"this line solved my problem.
– Yogesh Katkar
Nov 14 '18 at 11:29
@YogeshKatkar Yes that will required as you are using ConstraintLayout you need to set constraints. I thought you would be doing all these things, only height is not working.
– Pankaj Kumar
Nov 14 '18 at 11:30
I used left,right and top only bottom constraint was missing.
– Yogesh Katkar
Nov 14 '18 at 11:31
Thanks for the answer @Pankaj. I already did it, but did not help.
– Yogesh Katkar
Nov 14 '18 at 11:22
Thanks for the answer @Pankaj. I already did it, but did not help.
– Yogesh Katkar
Nov 14 '18 at 11:22
Then better to add your layout code.
– Pankaj Kumar
Nov 14 '18 at 11:23
Then better to add your layout code.
– Pankaj Kumar
Nov 14 '18 at 11:23
Not only
android:layout_height="0dp" but adding app:layout_constraintBottom_toBottomOf="parent" this line solved my problem.– Yogesh Katkar
Nov 14 '18 at 11:29
Not only
android:layout_height="0dp" but adding app:layout_constraintBottom_toBottomOf="parent" this line solved my problem.– Yogesh Katkar
Nov 14 '18 at 11:29
@YogeshKatkar Yes that will required as you are using ConstraintLayout you need to set constraints. I thought you would be doing all these things, only height is not working.
– Pankaj Kumar
Nov 14 '18 at 11:30
@YogeshKatkar Yes that will required as you are using ConstraintLayout you need to set constraints. I thought you would be doing all these things, only height is not working.
– Pankaj Kumar
Nov 14 '18 at 11:30
I used left,right and top only bottom constraint was missing.
– Yogesh Katkar
Nov 14 '18 at 11:31
I used left,right and top only bottom constraint was missing.
– Yogesh Katkar
Nov 14 '18 at 11:31
add a comment |
Note, that unlike other viewgroups in android, constraintlayout should have circular dependencies between the child views. Herewith, you should use 0dp instead of 'match_parent' width and constraints for each side of the child view.
<android.support.constraint.ConstraintLayout
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="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
</android.support.constraint.ConstraintLayout>
add a comment |
Note, that unlike other viewgroups in android, constraintlayout should have circular dependencies between the child views. Herewith, you should use 0dp instead of 'match_parent' width and constraints for each side of the child view.
<android.support.constraint.ConstraintLayout
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="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
</android.support.constraint.ConstraintLayout>
add a comment |
Note, that unlike other viewgroups in android, constraintlayout should have circular dependencies between the child views. Herewith, you should use 0dp instead of 'match_parent' width and constraints for each side of the child view.
<android.support.constraint.ConstraintLayout
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="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
</android.support.constraint.ConstraintLayout>
Note, that unlike other viewgroups in android, constraintlayout should have circular dependencies between the child views. Herewith, you should use 0dp instead of 'match_parent' width and constraints for each side of the child view.
<android.support.constraint.ConstraintLayout
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="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
</android.support.constraint.ConstraintLayout>
answered Nov 14 '18 at 11:23
OnixOnix
4578
4578
add a comment |
add a comment |
give the toolbar an id ,
and in your frame layout set the width and height to 0dp add the constraints like in this code..
<android.support.constraint.ConstraintLayout
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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Main2Activity">
<Toolbar
android:id="@+id/toolbar"
app:layout_constraintTop_toTopOf="parent"
android:background="#ab1010"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Toolbar>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="#f1f1df"
>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
add a comment |
give the toolbar an id ,
and in your frame layout set the width and height to 0dp add the constraints like in this code..
<android.support.constraint.ConstraintLayout
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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Main2Activity">
<Toolbar
android:id="@+id/toolbar"
app:layout_constraintTop_toTopOf="parent"
android:background="#ab1010"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Toolbar>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="#f1f1df"
>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
add a comment |
give the toolbar an id ,
and in your frame layout set the width and height to 0dp add the constraints like in this code..
<android.support.constraint.ConstraintLayout
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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Main2Activity">
<Toolbar
android:id="@+id/toolbar"
app:layout_constraintTop_toTopOf="parent"
android:background="#ab1010"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Toolbar>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="#f1f1df"
>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
give the toolbar an id ,
and in your frame layout set the width and height to 0dp add the constraints like in this code..
<android.support.constraint.ConstraintLayout
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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Main2Activity">
<Toolbar
android:id="@+id/toolbar"
app:layout_constraintTop_toTopOf="parent"
android:background="#ab1010"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Toolbar>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="#f1f1df"
>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
answered Nov 14 '18 at 11:36
OutlandishOutlandish
309
309
add a comment |
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.
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%2f53299024%2fhow-to-set-a-views-height-match-parent-in-constraintlayout%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
Possible duplicate of Set width to match constraints in ConstraintLayout
– Mr. Roshan
Nov 14 '18 at 11:23
Please see my solution and check if it is exactly how you need.
– Ümañg ßürmån
Nov 15 '18 at 5:11