小编Mat*_*oni的帖子

ConstraintLayout的孩子的边距不显示?

我正在为我的应用程序使用Android的新ConstraintLayout,并且我一直遇到有元素边缘显示的问题.作为参考,我在Gradle文件中使用ConstraintLayout中的以下行com.android.support.constraint:constraint-layout:1.0.0-beta4.我的布局中的代码如下.

<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="wrap_content"
    android:paddingStart="@dimen/activity_horizontal_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/post_vertical_padding"
    android:paddingEnd="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingBottom="@dimen/post_vertical_padding"
    android:background="?android:attr/selectableItemBackground">

    <TextView
        style="@style/TitleText"
        android:id="@+id/post_type"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/post_line_vertical_padding"
        android:layout_marginEnd="@dimen/post_type_horizontal_padding"
        android:layout_marginRight="@dimen/post_type_horizontal_padding"
        app:layout_constraintLeft_toRightOf="@id/poster_profile_pic"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/poster_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toRightOf="@id/post_type"
        app:layout_constraintBaseline_toBaselineOf="@id/post_type" />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

android android-constraintlayout

4
推荐指数
1
解决办法
9278
查看次数

只能在IEnumerable上调用Cast和OfType

在我正在使用的库中,遇到调用IEnumerable之外的任何LINQ方法的问题。我有一个如下的类层次结构(命名有点奇怪,因为它被内部代码所混淆了)

Item : GeneralObject

ItemCollection : GenericCollection<ItemCollection, Item>

GenericCollection<TCollection, TItem> : GeneralObjectCollection, IEnumerable<TItem>
    where TCollection : GenericCollection<TCollection, TItem>
    where TItem : GeneralObject

GeneralObjectCollection : ICollection, IEnumerable<GeneralObject>
Run Code Online (Sandbox Code Playgroud)

可以看出,IEnumerable在ItemCollection的类层次结构中有两次,因此有两种GetEnumerator方法,一种提供a GeneralObject,一种提供a Item

当我查看VS2019中通过元数据提供的类定义时,实现的每个类IEnumerable<TItem>也显示为Implemented IEnumerable

With this setup, I am unable to call most LINQ methods like Select, Where, etc, on any ItemCollection instances, and can only do those on IEnumerable. It looks like it should clearly support methods on IEnumerable<T> as well, but …

c# linq ienumerable

0
推荐指数
1
解决办法
254
查看次数