How to make a layout like this image using constraint layout
How to make this type of view in Android Studio using constraint layout
android
add a comment |
How to make this type of view in Android Studio using constraint layout
android
add a comment |
How to make this type of view in Android Studio using constraint layout
android
How to make this type of view in Android Studio using constraint layout
android
android
edited Nov 13 '18 at 16:06
Makyen
20.7k84075
20.7k84075
asked Nov 13 '18 at 14:41
MaryamMaryam
12
12
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If you're wondering about how to place the menu to fall half on the top view and half on the bottom view, just drag it manually to the position you want to have it, and on the design tab of Android studio select the Magic Wand icon, to "infer constraints". As for the views in the background make sure you add app:layout_constraintBottomToTopOf="yourBottomView"
to your view on top and app:layout_constraintTopToBottomOf="yourTopView"
.
Check the codelabs tutorial on Constraint Layout here for more info, or the documentation on the developers' website here
EDIT:
<?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">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:color/holo_blue_bright" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView"
app:srcCompat="@android:color/darker_gray" />
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="@+id/textView2"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="@+id/textView3"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
This is what I get from the above:
No this rounded view has adjusted ht these three buttons and textviews are not come in center on changing multiple devices.
– Maryam
Nov 14 '18 at 7:52
@Maryam I would organise the three buttons/textviews into a separate constraint layout within the bigger layout, to make sure you keep the balance, and then constraint that layout as one item, instead of trying to center each of the views
– Nikos Hidalgo
Nov 14 '18 at 9:35
@Maryam I edited my answer to include some guideline code for the layout
– Nikos Hidalgo
Nov 14 '18 at 10:19
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%2f53283455%2fhow-to-make-a-layout-like-this-image-using-constraint-layout%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you're wondering about how to place the menu to fall half on the top view and half on the bottom view, just drag it manually to the position you want to have it, and on the design tab of Android studio select the Magic Wand icon, to "infer constraints". As for the views in the background make sure you add app:layout_constraintBottomToTopOf="yourBottomView"
to your view on top and app:layout_constraintTopToBottomOf="yourTopView"
.
Check the codelabs tutorial on Constraint Layout here for more info, or the documentation on the developers' website here
EDIT:
<?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">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:color/holo_blue_bright" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView"
app:srcCompat="@android:color/darker_gray" />
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="@+id/textView2"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="@+id/textView3"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
This is what I get from the above:
No this rounded view has adjusted ht these three buttons and textviews are not come in center on changing multiple devices.
– Maryam
Nov 14 '18 at 7:52
@Maryam I would organise the three buttons/textviews into a separate constraint layout within the bigger layout, to make sure you keep the balance, and then constraint that layout as one item, instead of trying to center each of the views
– Nikos Hidalgo
Nov 14 '18 at 9:35
@Maryam I edited my answer to include some guideline code for the layout
– Nikos Hidalgo
Nov 14 '18 at 10:19
add a comment |
If you're wondering about how to place the menu to fall half on the top view and half on the bottom view, just drag it manually to the position you want to have it, and on the design tab of Android studio select the Magic Wand icon, to "infer constraints". As for the views in the background make sure you add app:layout_constraintBottomToTopOf="yourBottomView"
to your view on top and app:layout_constraintTopToBottomOf="yourTopView"
.
Check the codelabs tutorial on Constraint Layout here for more info, or the documentation on the developers' website here
EDIT:
<?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">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:color/holo_blue_bright" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView"
app:srcCompat="@android:color/darker_gray" />
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="@+id/textView2"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="@+id/textView3"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
This is what I get from the above:
No this rounded view has adjusted ht these three buttons and textviews are not come in center on changing multiple devices.
– Maryam
Nov 14 '18 at 7:52
@Maryam I would organise the three buttons/textviews into a separate constraint layout within the bigger layout, to make sure you keep the balance, and then constraint that layout as one item, instead of trying to center each of the views
– Nikos Hidalgo
Nov 14 '18 at 9:35
@Maryam I edited my answer to include some guideline code for the layout
– Nikos Hidalgo
Nov 14 '18 at 10:19
add a comment |
If you're wondering about how to place the menu to fall half on the top view and half on the bottom view, just drag it manually to the position you want to have it, and on the design tab of Android studio select the Magic Wand icon, to "infer constraints". As for the views in the background make sure you add app:layout_constraintBottomToTopOf="yourBottomView"
to your view on top and app:layout_constraintTopToBottomOf="yourTopView"
.
Check the codelabs tutorial on Constraint Layout here for more info, or the documentation on the developers' website here
EDIT:
<?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">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:color/holo_blue_bright" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView"
app:srcCompat="@android:color/darker_gray" />
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="@+id/textView2"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="@+id/textView3"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
This is what I get from the above:
If you're wondering about how to place the menu to fall half on the top view and half on the bottom view, just drag it manually to the position you want to have it, and on the design tab of Android studio select the Magic Wand icon, to "infer constraints". As for the views in the background make sure you add app:layout_constraintBottomToTopOf="yourBottomView"
to your view on top and app:layout_constraintTopToBottomOf="yourTopView"
.
Check the codelabs tutorial on Constraint Layout here for more info, or the documentation on the developers' website here
EDIT:
<?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">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:color/holo_blue_bright" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView"
app:srcCompat="@android:color/darker_gray" />
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="@+id/textView2"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="@+id/textView3"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
This is what I get from the above:
edited Nov 14 '18 at 10:19
answered Nov 13 '18 at 15:16
Nikos HidalgoNikos Hidalgo
1,1781318
1,1781318
No this rounded view has adjusted ht these three buttons and textviews are not come in center on changing multiple devices.
– Maryam
Nov 14 '18 at 7:52
@Maryam I would organise the three buttons/textviews into a separate constraint layout within the bigger layout, to make sure you keep the balance, and then constraint that layout as one item, instead of trying to center each of the views
– Nikos Hidalgo
Nov 14 '18 at 9:35
@Maryam I edited my answer to include some guideline code for the layout
– Nikos Hidalgo
Nov 14 '18 at 10:19
add a comment |
No this rounded view has adjusted ht these three buttons and textviews are not come in center on changing multiple devices.
– Maryam
Nov 14 '18 at 7:52
@Maryam I would organise the three buttons/textviews into a separate constraint layout within the bigger layout, to make sure you keep the balance, and then constraint that layout as one item, instead of trying to center each of the views
– Nikos Hidalgo
Nov 14 '18 at 9:35
@Maryam I edited my answer to include some guideline code for the layout
– Nikos Hidalgo
Nov 14 '18 at 10:19
No this rounded view has adjusted ht these three buttons and textviews are not come in center on changing multiple devices.
– Maryam
Nov 14 '18 at 7:52
No this rounded view has adjusted ht these three buttons and textviews are not come in center on changing multiple devices.
– Maryam
Nov 14 '18 at 7:52
@Maryam I would organise the three buttons/textviews into a separate constraint layout within the bigger layout, to make sure you keep the balance, and then constraint that layout as one item, instead of trying to center each of the views
– Nikos Hidalgo
Nov 14 '18 at 9:35
@Maryam I would organise the three buttons/textviews into a separate constraint layout within the bigger layout, to make sure you keep the balance, and then constraint that layout as one item, instead of trying to center each of the views
– Nikos Hidalgo
Nov 14 '18 at 9:35
@Maryam I edited my answer to include some guideline code for the layout
– Nikos Hidalgo
Nov 14 '18 at 10:19
@Maryam I edited my answer to include some guideline code for the layout
– Nikos Hidalgo
Nov 14 '18 at 10:19
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%2f53283455%2fhow-to-make-a-layout-like-this-image-using-constraint-layout%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