【发布时间】:2018-07-05 17:34:26
【问题描述】:
我有下面列出的 Android 布局,但 layout_marginBottom 不起作用 - myTextView 和 myRecyclerView 之间没有任何边距。
任何想法,我的布局可能有什么问题?
<?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"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/myTextView"
android:text="*** Descritpion text"
app:layout_constraintWidth_default="spread"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/myRecyclerView"
android:layout_marginBottom="300dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/myRecyclerView"
app:layout_constraintTop_toBottomOf="@+id/myTextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintVertical_bias="0"
app:layout_constraintWidth_default="spread"
app:layout_constraintHeight_default="wrap"
android:layout_width="0dp"
android:layout_height="0dp" />
</android.support.constraint.ConstraintLayout>
【问题讨论】:
-
您使用的是哪个版本的
ConstraintLayout? -
@Cheticamp 1.1.0
-
我有一些非常相似的地方,没有添加顶部和底部边距。当在链中或不在链中时。我正在使用 1.1.2,ui 设计器显示它很好,但是当构建并推送到应用程序时......它消失了,尤其是在使用包含布局时