pal*_*ara 5 android android-recyclerview android-constraintlayout
最近,我开始使用Constraint布局,但今天使用它遇到了非常奇怪的行为.当我在fragment_holiday.xml中使用RelativeLayout作为root而不是ConstraintLayout时,输出正如预期的那样,但我想知道ConstraintLayout有什么问题.片段,item_row的代码如下
而且我得到了约束布局的输出(并且在滚动它显示不同的beheviour,你可以在我正在分享的截图中看到)---

fragment_holiday.xml
<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"
tools:context="com.thepsi.psidashboard.Fragments.HolidayFragment">
<com.thepsi.psidashboard.CustomViews.CustomDatePicker
android:id="@+id/customDatePicker_holiday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:dateFormat="MONTH_YEAR"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycle_view_holiday"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/general_margin_eight_dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/customDatePicker_holiday" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
item_holiday.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="wrap_content">
<TextView
android:id="@+id/textView25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="24 - January - 2017"
android:textColor="@color/colorPrimaryDark"
/>
<TextView
android:id="@+id/textView26"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="Saturday"
android:layout_alignParentEnd="true"
android:textColor="@color/colorPrimaryDark"
/>
<TextView
android:id="@+id/textView27"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:text="Mahavir Jayanti"
android:textAlignment="center"
android:textColor="@android:color/black"
android:layout_below="@+id/textView25"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
预期设计 -
谁能告诉我这里缺少什么?
Arn*_*own 11
试试这个...
改变宽度的recyclerview作为matchparent
是啊!根据文档,ConstraintLayout中的小部件不支持matchparent作为宽度.
我们必须将宽度指定为0dp并使用constraintStart_toStartOf ="parent"和constraintEnd_toEndOf ="parent"来反映您使用的matchparent.
但是我给出的解决方案可以解决一些案例.
| 归档时间: |
|
| 查看次数: |
1008 次 |
| 最近记录: |