How to get barriers to work with MotionLayout











up vote
0
down vote

favorite












So I have been playing around with MotionLayout to get certain animations to work, but I had an issue with barriers when converting the ConstraintLayout to the MotionLayout. I have a barrier that references two header views on the top of the parent layout and a ViewGroup that constrains the top of the ViewGroup to the bottom of the barrier; however, when I convert the ConstraintLayout to the new MotionLayout, the barrier does not work anymore. My ViewGroup gets constrained to the top of the parent instead of the bottom of the barrier. I assume this is because the library is still in alpha, but I'm hoping someone has some sort of workaround on that.



Edit:



<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout
usual stuff here
app:layoutDescription="@xml/scene">

<CustomHeaderView
android:id="@+id/first_header"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="gone"
app:attachedRecyclerView="@+id/some_recycler_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<SecondCustomHeaderView
android:id="@+id/second_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
app:attachedRecyclerView="@+id/some_recycler_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<android.support.constraint.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="first_header,second_header"
tools:layout_editor_absoluteY="241dp" />

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/some_swipe_container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/barrier"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/some_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:nestedScrollingEnabled="false" />

</android.support.v4.widget.NestedScrollView>

</android.support.v4.widget.SwipeRefreshLayout>


</android.support.constraint.motion.MotionLayout>


Thanks!










share|improve this question




















  • 1




    Hey, could you post the relevant code that you have so far?
    – RX9
    Nov 7 at 15:33










  • Although not answering your question, the Android Dev Summit is today and there is a Session on ConstraintLayout and what's new in 2.0 which may be helpful to you. developer.android.com/dev-summit/schedule/day1
    – teh_raab
    Nov 7 at 15:33










  • @RX9 Yeah, give me a moment to post some shortened down code.
    – Sam Lee
    Nov 7 at 15:34










  • @RX9 The code is up!
    – Sam Lee
    Nov 7 at 15:44










  • @teh_raab Thanks for the link! I'll be sure to check that out after work.
    – Sam Lee
    Nov 7 at 15:45















up vote
0
down vote

favorite












So I have been playing around with MotionLayout to get certain animations to work, but I had an issue with barriers when converting the ConstraintLayout to the MotionLayout. I have a barrier that references two header views on the top of the parent layout and a ViewGroup that constrains the top of the ViewGroup to the bottom of the barrier; however, when I convert the ConstraintLayout to the new MotionLayout, the barrier does not work anymore. My ViewGroup gets constrained to the top of the parent instead of the bottom of the barrier. I assume this is because the library is still in alpha, but I'm hoping someone has some sort of workaround on that.



Edit:



<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout
usual stuff here
app:layoutDescription="@xml/scene">

<CustomHeaderView
android:id="@+id/first_header"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="gone"
app:attachedRecyclerView="@+id/some_recycler_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<SecondCustomHeaderView
android:id="@+id/second_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
app:attachedRecyclerView="@+id/some_recycler_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<android.support.constraint.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="first_header,second_header"
tools:layout_editor_absoluteY="241dp" />

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/some_swipe_container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/barrier"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/some_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:nestedScrollingEnabled="false" />

</android.support.v4.widget.NestedScrollView>

</android.support.v4.widget.SwipeRefreshLayout>


</android.support.constraint.motion.MotionLayout>


Thanks!










share|improve this question




















  • 1




    Hey, could you post the relevant code that you have so far?
    – RX9
    Nov 7 at 15:33










  • Although not answering your question, the Android Dev Summit is today and there is a Session on ConstraintLayout and what's new in 2.0 which may be helpful to you. developer.android.com/dev-summit/schedule/day1
    – teh_raab
    Nov 7 at 15:33










  • @RX9 Yeah, give me a moment to post some shortened down code.
    – Sam Lee
    Nov 7 at 15:34










  • @RX9 The code is up!
    – Sam Lee
    Nov 7 at 15:44










  • @teh_raab Thanks for the link! I'll be sure to check that out after work.
    – Sam Lee
    Nov 7 at 15:45













up vote
0
down vote

favorite









up vote
0
down vote

favorite











So I have been playing around with MotionLayout to get certain animations to work, but I had an issue with barriers when converting the ConstraintLayout to the MotionLayout. I have a barrier that references two header views on the top of the parent layout and a ViewGroup that constrains the top of the ViewGroup to the bottom of the barrier; however, when I convert the ConstraintLayout to the new MotionLayout, the barrier does not work anymore. My ViewGroup gets constrained to the top of the parent instead of the bottom of the barrier. I assume this is because the library is still in alpha, but I'm hoping someone has some sort of workaround on that.



Edit:



<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout
usual stuff here
app:layoutDescription="@xml/scene">

<CustomHeaderView
android:id="@+id/first_header"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="gone"
app:attachedRecyclerView="@+id/some_recycler_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<SecondCustomHeaderView
android:id="@+id/second_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
app:attachedRecyclerView="@+id/some_recycler_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<android.support.constraint.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="first_header,second_header"
tools:layout_editor_absoluteY="241dp" />

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/some_swipe_container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/barrier"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/some_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:nestedScrollingEnabled="false" />

</android.support.v4.widget.NestedScrollView>

</android.support.v4.widget.SwipeRefreshLayout>


</android.support.constraint.motion.MotionLayout>


Thanks!










share|improve this question















So I have been playing around with MotionLayout to get certain animations to work, but I had an issue with barriers when converting the ConstraintLayout to the MotionLayout. I have a barrier that references two header views on the top of the parent layout and a ViewGroup that constrains the top of the ViewGroup to the bottom of the barrier; however, when I convert the ConstraintLayout to the new MotionLayout, the barrier does not work anymore. My ViewGroup gets constrained to the top of the parent instead of the bottom of the barrier. I assume this is because the library is still in alpha, but I'm hoping someone has some sort of workaround on that.



Edit:



<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout
usual stuff here
app:layoutDescription="@xml/scene">

<CustomHeaderView
android:id="@+id/first_header"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="gone"
app:attachedRecyclerView="@+id/some_recycler_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<SecondCustomHeaderView
android:id="@+id/second_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
app:attachedRecyclerView="@+id/some_recycler_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<android.support.constraint.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="first_header,second_header"
tools:layout_editor_absoluteY="241dp" />

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/some_swipe_container"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/barrier"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/some_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:nestedScrollingEnabled="false" />

</android.support.v4.widget.NestedScrollView>

</android.support.v4.widget.SwipeRefreshLayout>


</android.support.constraint.motion.MotionLayout>


Thanks!







android android-motionlayout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 15:44

























asked Nov 7 at 15:26









Sam Lee

12




12








  • 1




    Hey, could you post the relevant code that you have so far?
    – RX9
    Nov 7 at 15:33










  • Although not answering your question, the Android Dev Summit is today and there is a Session on ConstraintLayout and what's new in 2.0 which may be helpful to you. developer.android.com/dev-summit/schedule/day1
    – teh_raab
    Nov 7 at 15:33










  • @RX9 Yeah, give me a moment to post some shortened down code.
    – Sam Lee
    Nov 7 at 15:34










  • @RX9 The code is up!
    – Sam Lee
    Nov 7 at 15:44










  • @teh_raab Thanks for the link! I'll be sure to check that out after work.
    – Sam Lee
    Nov 7 at 15:45














  • 1




    Hey, could you post the relevant code that you have so far?
    – RX9
    Nov 7 at 15:33










  • Although not answering your question, the Android Dev Summit is today and there is a Session on ConstraintLayout and what's new in 2.0 which may be helpful to you. developer.android.com/dev-summit/schedule/day1
    – teh_raab
    Nov 7 at 15:33










  • @RX9 Yeah, give me a moment to post some shortened down code.
    – Sam Lee
    Nov 7 at 15:34










  • @RX9 The code is up!
    – Sam Lee
    Nov 7 at 15:44










  • @teh_raab Thanks for the link! I'll be sure to check that out after work.
    – Sam Lee
    Nov 7 at 15:45








1




1




Hey, could you post the relevant code that you have so far?
– RX9
Nov 7 at 15:33




Hey, could you post the relevant code that you have so far?
– RX9
Nov 7 at 15:33












Although not answering your question, the Android Dev Summit is today and there is a Session on ConstraintLayout and what's new in 2.0 which may be helpful to you. developer.android.com/dev-summit/schedule/day1
– teh_raab
Nov 7 at 15:33




Although not answering your question, the Android Dev Summit is today and there is a Session on ConstraintLayout and what's new in 2.0 which may be helpful to you. developer.android.com/dev-summit/schedule/day1
– teh_raab
Nov 7 at 15:33












@RX9 Yeah, give me a moment to post some shortened down code.
– Sam Lee
Nov 7 at 15:34




@RX9 Yeah, give me a moment to post some shortened down code.
– Sam Lee
Nov 7 at 15:34












@RX9 The code is up!
– Sam Lee
Nov 7 at 15:44




@RX9 The code is up!
– Sam Lee
Nov 7 at 15:44












@teh_raab Thanks for the link! I'll be sure to check that out after work.
– Sam Lee
Nov 7 at 15:45




@teh_raab Thanks for the link! I'll be sure to check that out after work.
– Sam Lee
Nov 7 at 15:45

















active

oldest

votes











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',
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%2f53192538%2fhow-to-get-barriers-to-work-with-motionlayout%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53192538%2fhow-to-get-barriers-to-work-with-motionlayout%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







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()