2017-12-11 10 views
1

を歪める私の元layoutコードた:なぜ制約レイアウトにconvertngないビュー

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<com.udacity.gradle.builditbigger.Camera.AutoFitTextureView 
    android:id="@+id/textureView" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="3"/> 

<android.support.v7.widget.RecyclerView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:id="@+id/photo_thumbnail_recyclerview" 
    android:layout_weight="1"/> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="snap" 
    android:id="@+id/snap"/> 

</LinearLayout> 

textureViewフラグメントのかなりの量を占めます。私は以下のコードに示すように、制約レイアウトを持つに切り替えるとき:

<?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" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

<com.udacity.gradle.builditbigger.Camera.AutoFitTextureView 
    android:id="@+id/textureView" 
    android:layout_width="0dp" 
    android:layout_height="0dp" 
    android:layout_marginBottom="8dp" 
    app:layout_constraintBottom_toTopOf="@+id/photo_thumbnail_recyclerview" 
    app:layout_constraintEnd_toEndOf="parent" 
    app:layout_constraintStart_toStartOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    /> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/photo_thumbnail_recyclerview" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="8dp" 
    app:layout_constraintBottom_toBottomOf="parent" 
    app:layout_constraintEnd_toEndOf="parent" 
    app:layout_constraintStart_toStartOf="parent" 
    /> 

<ImageButton 
    android:id="@+id/switchcamera_imageButton" 
    android:layout_width="75dp" 
    android:layout_height="75dp" 
    android:layout_marginBottom="8dp" 
    android:layout_marginEnd="8dp" 
    android:background="@null" 
    android:scaleType="fitCenter" 
    app:layout_constraintBottom_toBottomOf="@+id/textureView" 
    app:layout_constraintEnd_toEndOf="parent" 
    app:srcCompat="@drawable/ic_switch_camera_white_24px" /> 

<ImageButton 
    android:id="@+id/takepicture_imageButton" 
    android:layout_width="75dp" 
    android:layout_height="75dp" 
    android:layout_marginBottom="8dp" 
    android:background="@null" 
    android:scaleType="fitCenter" 
    app:layout_constraintBottom_toBottomOf="@+id/textureView" 
    app:layout_constraintEnd_toEndOf="parent" 
    app:layout_constraintHorizontal_bias="0.5" 
    app:layout_constraintStart_toStartOf="parent" 
    app:srcCompat="@drawable/ic_camera_white_24px" /> 

</android.support.constraint.ConstraintLayout> 

テクスチャviewは唯一私が欲しいものである親fragmentの幅を占めます。しかし、高さは、imagebuttonsの高さをあまり超えていないので、textureViewの底部に位置する必要があります。また、recyclerviewは表示されません。理由は何ですか?

答えて

0

私が望むレイアウトを得るために、制約レイアウトから相対レイアウトに切り替えました

関連する問題