【问题标题】:Effect with margins?对边距的影响?
【发布时间】:2019-05-18 03:37:46
【问题描述】:

设计是一个Linearlayout,里面有一个cardivew和一个背景颜色,就这么简单。

通过单击任何视图(视图 1、视图 2 ...)动态添加其他布局。这些新布局“推动”了包含 Cardview 的 Linearlayout。我认为这不会影响我想要达到的效果。

我想得到你在下一张图片中看到的效果。

有什么想法吗?

【问题讨论】:

    标签: android android-layout android-layout-editor


    【解决方案1】:

    为此,您需要使用 ConstraintLayout

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    
      <android.support.v7.widget.CardView
        android:id="@+id/abc"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        app:layout_constraintTop_toTopOf="linearLayout"
        app:layout_constraintBottom_toTopOf="linearLayout"/>
    
       <LinearLayout>
       ....Your Layout Code.....
       </LinearLayout/>
    
    </android.support.constraint.ConstraintLayout>
    

    【讨论】:

      猜你喜欢
      • 2015-07-16
      • 2013-08-06
      • 2020-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-22
      • 2013-01-19
      • 1970-01-01
      相关资源
      最近更新 更多