我认为我很好地控制了Constraint Layout。但这个高度问题很奇怪。
问题
ConstraintLayout
@id/boarding
@id/progress_layout
正确占据@id/take_off_button
和@id/boarding_counter
之间的全高。但它的子@id/runway
和width:0dp
并没有占据父母的整个高度。我已经为孩子定义了正确的属性:app:layout_constraintTop_toTopOf="parent",app:layout_constraintBottom_toBottomOf="parent"
,<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:transitionName="@string/transition_send_to_clip_verification">
<include layout="@layout/toolbar" />
<android.support.constraint.ConstraintLayout
android:id="@+id/layout_content"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar">
<android.support.constraint.ConstraintLayout
android:id="@+id/progress_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/boarding"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:id="@+id/progress1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="@dimen/padding_left_right"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/divider1"
app:layout_constraintTop_toTopOf="parent">
<TextView
style="@style/text_12_bold_primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_send"
android:gravity="center"
android:text="Check In"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
<View
android:id="@+id/divider1"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/text_primary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_weight="0.5"
app:layout_constraintLeft_toRightOf="@id/progress1"
app:layout_constraintRight_toLeftOf="@id/progress2"
app:layout_constraintTop_toTopOf="parent"></View>
<android.support.constraint.ConstraintLayout
android:id="@+id/progress2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="@dimen/padding_left_right"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@id/divider1"
app:layout_constraintRight_toLeftOf="@+id/divider2"
app:layout_constraintTop_toTopOf="parent">
<TextView
style="@style/text_12_bold_primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_send"
android:gravity="center"
android:text="Choose destination"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
<View
android:id="@+id/divider2"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/text_primary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_weight="0.5"
app:layout_constraintLeft_toRightOf="@id/progress2"
app:layout_constraintRight_toLeftOf="@id/progress3"
app:layout_constraintTop_toTopOf="parent"></View>
<android.support.constraint.ConstraintLayout
android:id="@+id/progress3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="@dimen/padding_left_right"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@id/divider2"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
style="@style/text_12_bold_primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_send"
android:gravity="center"
android:text="Take Off"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/boarding"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/take_off_button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/progress_layout">
<android.support.v7.widget.RecyclerView
android:id="@+id/boarding_counter"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHeight_default="spread"
app:layout_constraintRight_toLeftOf="@+id/runway"
app:layout_constraintTop_toTopOf="parent"></android.support.v7.widget.RecyclerView>
<android.support.constraint.ConstraintLayout
android:id="@+id/runway"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_default="spread"
app:layout_constraintLeft_toRightOf="@id/boarding_counter"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_road" />
<android.support.v7.widget.RecyclerView
android:id="@+id/taxis"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"></android.support.v7.widget.RecyclerView>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/take_off_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/color_primary_bg"
android:padding="@dimen/padding_top_bottom"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/boarding">
<TextView
style="@style/text_16_bold"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TAKE OFF"
android:textColor="@color/colorPrimary"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
,他们只是采取部分随机高度。
请帮忙
@id/taxis
更新
更改库版本但暂时有效。当我在Recycler View private async void SaveasGIF(object sender, RoutedEventArgs e)
{
var savePicker = new Windows.Storage.Pickers.FileSavePicker();
savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
savePicker.FileTypeChoices.Add("Gif with embedded ISF", new[] { ".gif" });
Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
if (null != file)
{
try
{
using (Windows.Storage.Streams.IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite))
{
// Truncate any existing stream in case the new file
// is smaller than the old file.
stream.Size = 0;
await MyInkCanvas.InkPresenter.StrokeContainer.SaveAsync(stream);
}
//MainPage.NotifyUser("File has been saved!", NotifyType.StatusMessage);
}
catch (Exception ex)
{
//MainPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
}
}
SaveGIF.IsChecked = false;
}
中添加项目时,高度再次降低到一半。
以下是视频:
答案 0 :(得分:1)
更新到ConstraintLayout
1.1.0-beta3以解决此问题:
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta3'
如果您稍后无法更新,尽管是测试版,请回复备用解决方案。