Fix views in comment toolbar overlapping each other.

This commit is contained in:
Alex Ning 2022-01-21 15:44:49 +08:00
parent c6f5e3c8f6
commit de105359f9
3 changed files with 93 additions and 33 deletions

View File

@ -369,6 +369,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
TextView scoreTextView; TextView scoreTextView;
@BindView(R.id.down_vote_button_item_post_comment) @BindView(R.id.down_vote_button_item_post_comment)
ImageView downvoteButton; ImageView downvoteButton;
@BindView(R.id.placeholder_item_post_comment)
View placeholder;
@BindView(R.id.more_button_item_post_comment) @BindView(R.id.more_button_item_post_comment)
ImageView moreButton; ImageView moreButton;
@BindView(R.id.save_button_item_post_comment) @BindView(R.id.save_button_item_post_comment)
@ -390,19 +392,35 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
ConstraintSet constraintSet = new ConstraintSet(); ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(bottomConstraintLayout); constraintSet.clone(bottomConstraintLayout);
constraintSet.clear(upvoteButton.getId(), ConstraintSet.START); constraintSet.clear(upvoteButton.getId(), ConstraintSet.START);
constraintSet.clear(upvoteButton.getId(), ConstraintSet.END);
constraintSet.clear(scoreTextView.getId(), ConstraintSet.START); constraintSet.clear(scoreTextView.getId(), ConstraintSet.START);
constraintSet.clear(scoreTextView.getId(), ConstraintSet.END);
constraintSet.clear(downvoteButton.getId(), ConstraintSet.START); constraintSet.clear(downvoteButton.getId(), ConstraintSet.START);
constraintSet.clear(downvoteButton.getId(), ConstraintSet.END);
constraintSet.clear(expandButton.getId(), ConstraintSet.START);
constraintSet.clear(expandButton.getId(), ConstraintSet.END); constraintSet.clear(expandButton.getId(), ConstraintSet.END);
constraintSet.clear(saveButton.getId(), ConstraintSet.START);
constraintSet.clear(saveButton.getId(), ConstraintSet.END);
constraintSet.clear(replyButton.getId(), ConstraintSet.START);
constraintSet.clear(replyButton.getId(), ConstraintSet.END); constraintSet.clear(replyButton.getId(), ConstraintSet.END);
constraintSet.clear(moreButton.getId(), ConstraintSet.START);
constraintSet.clear(moreButton.getId(), ConstraintSet.END);
constraintSet.connect(upvoteButton.getId(), ConstraintSet.END, scoreTextView.getId(), ConstraintSet.START); constraintSet.connect(upvoteButton.getId(), ConstraintSet.END, scoreTextView.getId(), ConstraintSet.START);
constraintSet.connect(upvoteButton.getId(), ConstraintSet.START, placeholder.getId(), ConstraintSet.END);
constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downvoteButton.getId(), ConstraintSet.START); constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downvoteButton.getId(), ConstraintSet.START);
constraintSet.connect(scoreTextView.getId(), ConstraintSet.START, upvoteButton.getId(), ConstraintSet.END);
constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END); constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
constraintSet.connect(saveButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START); constraintSet.connect(downvoteButton.getId(), ConstraintSet.START, scoreTextView.getId(), ConstraintSet.END);
constraintSet.connect(moreButton.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END); constraintSet.connect(placeholder.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.START);
constraintSet.connect(moreButton.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.END); constraintSet.connect(placeholder.getId(), ConstraintSet.START, moreButton.getId(), ConstraintSet.END);
constraintSet.connect(expandButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END); constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END);
constraintSet.connect(replyButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END); constraintSet.connect(moreButton.getId(), ConstraintSet.END, placeholder.getId(), ConstraintSet.START);
constraintSet.setHorizontalBias(moreButton.getId(), 0); constraintSet.connect(expandButton.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END);
constraintSet.connect(expandButton.getId(), ConstraintSet.END, moreButton.getId(), ConstraintSet.START);
constraintSet.connect(saveButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END);
constraintSet.connect(saveButton.getId(), ConstraintSet.END, expandButton.getId(), ConstraintSet.START);
constraintSet.connect(replyButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
constraintSet.connect(replyButton.getId(), ConstraintSet.END, saveButton.getId(), ConstraintSet.START);
constraintSet.applyTo(bottomConstraintLayout); constraintSet.applyTo(bottomConstraintLayout);
} }

View File

@ -1098,6 +1098,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
TextView scoreTextView; TextView scoreTextView;
@BindView(R.id.down_vote_button_item_post_comment) @BindView(R.id.down_vote_button_item_post_comment)
ImageView downvoteButton; ImageView downvoteButton;
@BindView(R.id.placeholder_item_post_comment)
View placeholder;
@BindView(R.id.more_button_item_post_comment) @BindView(R.id.more_button_item_post_comment)
ImageView moreButton; ImageView moreButton;
@BindView(R.id.save_button_item_post_comment) @BindView(R.id.save_button_item_post_comment)
@ -1119,20 +1121,35 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
ConstraintSet constraintSet = new ConstraintSet(); ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(bottomConstraintLayout); constraintSet.clone(bottomConstraintLayout);
constraintSet.clear(upvoteButton.getId(), ConstraintSet.START); constraintSet.clear(upvoteButton.getId(), ConstraintSet.START);
constraintSet.clear(upvoteButton.getId(), ConstraintSet.END);
constraintSet.clear(scoreTextView.getId(), ConstraintSet.START); constraintSet.clear(scoreTextView.getId(), ConstraintSet.START);
constraintSet.clear(scoreTextView.getId(), ConstraintSet.END);
constraintSet.clear(downvoteButton.getId(), ConstraintSet.START); constraintSet.clear(downvoteButton.getId(), ConstraintSet.START);
constraintSet.clear(downvoteButton.getId(), ConstraintSet.END);
constraintSet.clear(expandButton.getId(), ConstraintSet.START);
constraintSet.clear(expandButton.getId(), ConstraintSet.END); constraintSet.clear(expandButton.getId(), ConstraintSet.END);
constraintSet.clear(saveButton.getId(), ConstraintSet.START);
constraintSet.clear(saveButton.getId(), ConstraintSet.END); constraintSet.clear(saveButton.getId(), ConstraintSet.END);
constraintSet.clear(replyButton.getId(), ConstraintSet.START);
constraintSet.clear(replyButton.getId(), ConstraintSet.END); constraintSet.clear(replyButton.getId(), ConstraintSet.END);
constraintSet.clear(moreButton.getId(), ConstraintSet.START);
constraintSet.clear(moreButton.getId(), ConstraintSet.END); constraintSet.clear(moreButton.getId(), ConstraintSet.END);
constraintSet.connect(upvoteButton.getId(), ConstraintSet.END, scoreTextView.getId(), ConstraintSet.START); constraintSet.connect(upvoteButton.getId(), ConstraintSet.END, scoreTextView.getId(), ConstraintSet.START);
constraintSet.connect(upvoteButton.getId(), ConstraintSet.START, placeholder.getId(), ConstraintSet.END);
constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downvoteButton.getId(), ConstraintSet.START); constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downvoteButton.getId(), ConstraintSet.START);
constraintSet.connect(scoreTextView.getId(), ConstraintSet.START, upvoteButton.getId(), ConstraintSet.END);
constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END); constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
constraintSet.connect(downvoteButton.getId(), ConstraintSet.START, scoreTextView.getId(), ConstraintSet.END);
constraintSet.connect(placeholder.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.START);
constraintSet.connect(placeholder.getId(), ConstraintSet.START, moreButton.getId(), ConstraintSet.END);
constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END); constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END);
constraintSet.connect(moreButton.getId(), ConstraintSet.END, placeholder.getId(), ConstraintSet.START);
constraintSet.connect(expandButton.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END); constraintSet.connect(expandButton.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END);
constraintSet.connect(expandButton.getId(), ConstraintSet.END, moreButton.getId(), ConstraintSet.START);
constraintSet.connect(saveButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END); constraintSet.connect(saveButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END);
constraintSet.connect(saveButton.getId(), ConstraintSet.END, expandButton.getId(), ConstraintSet.START);
constraintSet.connect(replyButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START); constraintSet.connect(replyButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
constraintSet.setHorizontalBias(moreButton.getId(), 0); constraintSet.connect(replyButton.getId(), ConstraintSet.END, saveButton.getId(), ConstraintSet.START);
constraintSet.applyTo(bottomConstraintLayout); constraintSet.applyTo(bottomConstraintLayout);
} }

View File

@ -122,96 +122,121 @@
android:id="@+id/up_vote_button_item_post_comment" android:id="@+id/up_vote_button_item_post_comment"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="8dp"
android:src="@drawable/ic_arrow_upward_grey_24dp" android:src="@drawable/ic_arrow_upward_grey_24dp"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/score_text_view_item_post_comment"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintBottom_toBottomOf="parent" />
<TextView <TextView
android:id="@+id/score_text_view_item_post_comment" android:id="@+id/score_text_view_item_post_comment"
android:layout_width="64dp" android:layout_width="64dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:gravity="center" android:gravity="center"
android:textSize="?attr/font_12" android:textSize="?attr/font_12"
android:textStyle="bold" android:textStyle="bold"
android:fontFamily="?attr/font_family" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/down_vote_button_item_post_comment"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/up_vote_button_item_post_comment" app:layout_constraintStart_toEndOf="@+id/up_vote_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintBottom_toBottomOf="parent"/>
<ImageView <ImageView
android:id="@+id/down_vote_button_item_post_comment" android:id="@+id/down_vote_button_item_post_comment"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="8dp"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
app:layout_constraintStart_toEndOf="@+id/score_text_view_item_post_comment"
app:layout_constraintEnd_toStartOf="@id/more_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0" /> app:layout_constraintEnd_toStartOf="@+id/placeholder_item_post_comment"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/score_text_view_item_post_comment"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/placeholder_item_post_comment"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintWidth_min="1dp"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/more_button_item_post_comment"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/down_vote_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:id="@+id/more_button_item_post_comment" android:id="@+id/more_button_item_post_comment"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="8dp"
android:src="@drawable/ic_more_vert_grey_24dp" android:src="@drawable/ic_more_vert_grey_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/expand_button_item_post_comment" app:layout_constraintEnd_toStartOf="@+id/expand_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintStart_toEndOf="@+id/placeholder_item_post_comment"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/expand_button_item_post_comment" android:id="@+id/expand_button_item_post_comment"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"
android:fontFamily="?attr/font_family"
android:gravity="center" android:gravity="center"
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"
android:visibility="gone" android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/save_button_item_post_comment" app:layout_constraintEnd_toStartOf="@+id/save_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintStart_toEndOf="@+id/more_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:id="@+id/save_button_item_post_comment" android:id="@+id/save_button_item_post_comment"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/reply_button_item_post_comment" app:layout_constraintEnd_toStartOf="@+id/reply_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintStart_toEndOf="@+id/expand_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:id="@+id/reply_button_item_post_comment" android:id="@+id/reply_button_item_post_comment"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="8dp"
android:src="@drawable/ic_reply_grey_24dp" android:src="@drawable/ic_reply_grey_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintStart_toEndOf="@+id/save_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>