简体   繁体   English

如何在android studios中向现有链添加视图

[英]how to add a view to existing chain in android studios

I am creating individual test activities in android studios as i need them (before combining these tests into my project at a later date) so I have to periodically add more buttons to start new activities as they are added.我根据需要在 android studio 中创建单独的测试活动(在以后将这些测试组合到我的项目中之前),因此我必须定期添加更多按钮以在添加新活动时开始。 I have only found a long workaround of removing constraints and creating a new chain and resetting the constraints for each item (a tedious process as they are constrained to guidelines, so each have to be reset to 0dp each time)我只找到了一个很长的解决方法,即删除约束并创建新链并重置每个项目的约束(这是一个乏味的过程,因为它们受准则约束,因此每次都必须重置为 0dp)

Despite my experimenting with the IDE over the last couple months and googling /seacrching stackOverflow, i cannot find a way to simply 'add to existing chain' ie another (button) view to the bottom of a verical chain?尽管我在过去几个月对 IDE 进行了试验并在谷歌上搜索 /seacrching stackOverflow,但我找不到一种方法来简单地“添加到现有链”,即在垂直链的底部添加另一个(按钮)视图?

I don't know how to do it using design window, but you always can open code window with XML .我不知道如何使用设计窗口来做到这一点,但你总是可以用XML打开代码窗口。 The idea is that chain automatically generates when you constraining neighboring sides of two views.这个想法是当你约束两个视图的相邻边时,链会自动生成。 In the example below chain between two TextViews will appear:在下面的示例中,将出现两个 TextView 之间的链:

    <TextView
        android:id="@+id/view_1"
        ...
        app:layout_constraintRight_toLeftOf="@+id/view_2"/>

    <TextView
        android:id="@+id/view_2"
        ...
        app:layout_constraintLeft_toRightOf="@id/view_1"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM