2017-07-04 1 views
0

No Matter ce que j'écris à l'intérieur de Constraintset.connect pour changer la position, il reste toujours où il est (je veux qu'il se déplace de l'extérieur de l'écran dans l'écran du côté gauche), au moment où la vue est entièrement à l'intérieur de l'écran et seule la contrainte de gauche est manquante). Merci.ConstraintSet: Listview ne se déplacera pas correctement

ListViewItem:

<?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:background="#202020"> 

    <ImageView 
     android:id="@+id/listItemImageView" 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:layout_alignParentEnd="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginEnd="40dp" 
     android:layout_marginRight="16dp" 
     android:layout_marginTop="16dp" 
     android:paddingBottom="16dp" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     app:srcCompat="@mipmap/ic_launcher" /> 

    <TextView 
     android:id="@+id/listItemTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/listItemImageView" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="8dp" 
     android:layout_marginEnd="17dp" 
     android:layout_marginRight="17dp" 
     android:layout_marginTop="8dp" 
     android:layout_toLeftOf="@+id/listItemImageView" 
     android:layout_toStartOf="@+id/listItemImageView" 
     android:fontFamily="casual" 
     android:text="This Text will change" 
     android:textAlignment="viewStart" 
     android:textColor="@android:color/holo_green_dark" 
     android:textSize="18sp" 
     android:textStyle="bold" 
     app:layout_constraintBottom_toBottomOf="@+id/listItemImageView" 
     app:layout_constraintRight_toLeftOf="@+id/listItemImageView" 
     app:layout_constraintTop_toTopOf="parent" 
     app:layout_constraintVertical_bias="0.5" /> 
</android.support.constraint.ConstraintLayout> 

principal activity.xml

<?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:background="@android:color/black" 
    android:id="@+id/urlayout" 
    tools:context="com.example.me.gesturelaunchertest.MainActivity"> 
    <!-- Ab fadeduration sachen für I usw. --> 
    <android.gesture.GestureOverlayView 
     android:id="@+id/gesOverlay" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:layout_gravity="center_horizontal" 

     android:eventsInterceptionEnabled="true" 
     android:fadeDuration="300" 
     android:gestureStrokeAngleThreshold="0" 
     android:gestureStrokeLengthThreshold="300.0" 
     android:gestureStrokeSquarenessThreshold="0" 
     android:gestureColor="@android:color/white" 
     android:gestureStrokeWidth="40.0" 
     android:uncertainGestureColor="@android:color/darker_gray" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent"> 

    </android.gesture.GestureOverlayView> 

    <ListView 
     android:id="@+id/applistview" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="right" 
     android:layout_marginBottom="8dp" 
     android:layout_marginTop="8dp" 
     android:background="@android:color/transparent" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="20dp" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     app:layout_constraintVertical_bias="0.0" 
     android:layout_marginRight="113dp" 
     app:layout_constraintRight_toRightOf="parent" /> 


</android.support.constraint.ConstraintLayout> 

MainActivity:

  TransitionManager.beginDelayedTransition(constraintLayout); 
      constraintSet=new ConstraintSet(); 

      constraintSet.clone(constraintLayout); 

      constraintSet.connect(applistview.getId(), ConstraintSet.LEFT, constraintLayout.getId(), ConstraintSet.RIGHT, 110); 

      constraintSet.applyTo(constraintLayout); 

Répondre

1

Il semble y avoir un problème avec ConstraintSet.LEFT et ConstraintSet.RIGHT ne fonctionne pas. Voir this issue sur le bug tracker.

Essayez d'utiliser ConstraintSet.START et ConstraintSet.END à la place:

constraintSet.connect(applistview.getId(), ConstraintSet.START, 
     constraintLayout.getId(), ConstraintSet.END, 110); 

J'espère que cela aide.