无论我在Constraintset.connect中写什么来改变位置,它总是保持原样(我希望它从屏幕外移动到屏幕左侧),此时视图是完全在屏幕内部,只缺少左边约束)。 谢谢。
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>
主要活动文件
<?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);
答案 0 :(得分:1)
ConstraintSet.LEFT
和ConstraintSet.RIGHT
似乎无法解决问题。请参阅错误跟踪器上的this issue。
尝试改为使用ConstraintSet.START
和ConstraintSet.END
:
constraintSet.connect(applistview.getId(), ConstraintSet.START,
constraintLayout.getId(), ConstraintSet.END, 110);
我希望这会有所帮助。