4

図のように、ビューボックスは現在の位置に表示されますが、コンテンツは表示されません。テキストビューとイメージビューは、あたかもマージンがないかのようにレンダリングされます。私は、アプリケーションを実行すると、彼らはまた、適切にレンダリングされていない(2番目の画像)。私はそれが何を引き起こすのか分かりません。 Editor Preview Live DemoAndroid ConstraintLayoutマージンが正しく機能しない

編集:私は私のxmlを含めるのを忘れ:

<?xml version="1.0" encoding="utf-8"?> 
<com.example.android.stundenplanexample.dynamic_recyclerview.ExpandingCardView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/card_view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    card_view:cardCornerRadius="2dp" 
    card_view:cardElevation="2dp" 
    android:layout_margin="12dp"> 

    <android.support.constraint.ConstraintLayout 
     android:id="@+id/constraint" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <ImageView 
      android:layout_margin="8dp" 
      android:layout_width="24dp" 
      android:layout_height="24dp" 
      android:layout_weight="0" 
      android:src="@drawable/ic_expand_more_black_24dp" 
      android:id="@+id/card_expand_toggle" 
      tools:ignore="ContentDescription" 
      android:layout_marginTop="16dp" 
      card_view:layout_constraintTop_toTopOf="parent" 
      card_view:layout_constraintRight_toRightOf="parent" 
      android:layout_marginEnd="24dp" /> 

     <TextView 
      android:layout_margin="8dp" 
      android:layout_weight="1" 
      android:textAppearance="@android:style/TextAppearance.Material.Medium" 
      android:textColor="?android:attr/textColorPrimary" 
      android:layout_width="42dp" 
      android:layout_height="wrap_content" 
      android:text="@string/card_expand_string" 
      android:id="@+id/textView3" 
      card_view:layout_constraintTop_toTopOf="parent" 
      android:layout_marginStart="16dp" 
      card_view:layout_constraintLeft_toLeftOf="parent" 
      android:layout_marginTop="16dp" /> 

     <TextView 
      android:layout_height="wrap_content" 
      android:id="@+id/extra_information" 
      android:layout_width="wrap_content" 
      tools:text="ToleToleToleInfo" 
      card_view:layout_constraintLeft_toLeftOf="@+id/textView3" 
      android:layout_marginTop="8dp" 
      card_view:layout_constraintTop_toBottomOf="@+id/textView3" 
      card_view:layout_constraintBottom_toBottomOf="parent" 
      android:layout_marginBottom="16dp" /> 
    </android.support.constraint.ConstraintLayout> 

</com.example.android.stundenplanexample.dynamic_recyclerview.ExpandingCardView> 

答えて

1

私は1つの明確な問題と一つの潜在的な問題を参照してください。

明確な問題は、あなたのtextView3は、これらの属性を指定していることである:

android:layout_margin="8dp" 
android:layout_marginTop="16dp" 
android:layout_marginStart="16dp" 

これは、/セットトップ16dpと8DPするエンド/下に起動しません。単に、marginTopmarginStartの属性が無視されます。

潜在的な問題は、あなたが

android:layout_marginStart="16dp" 

を指定するだけでなく、marginLeftを指定していないということです。 API 17以前のデバイスをサポートする場合は、marginStartmarginLeftの両方を指定する必要があります(margin属性を削除した場合)。

+0

マージンは手動ではなく、デザインビューで設定しました。私はとにかくそれを試してみます、ありがとう、それは問題でした – BBotMerlin

+0

ありがとうございました。私は通常、これが動作するcssとhtmlで作業しているので、私はそれを見ていないと思う。 – BBotMerlin

+0

私はこれをバグとして報告することができます(エディタは正しく表示されていないため) – BBotMerlin

関連する問題