Scale avatar with text

This commit is contained in:
M66B 2019-03-08 09:15:40 +00:00
parent e65f5cbae4
commit f0e8e6211b
2 changed files with 16 additions and 2 deletions

View File

@ -469,6 +469,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvFrom.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
tvSubject.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
int px = Math.round(TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_PX, textSize * (compact ? 1.5f : 3.0f),
context.getResources().getDisplayMetrics()));
if (compact && tvFrom.getMinHeight() != px)
tvFrom.setMinimumHeight(px);
ViewGroup.LayoutParams lparams = ivAvatar.getLayoutParams();
if (lparams.height != px) {
lparams.width = px;
lparams.height = px;
ivAvatar.requestLayout();
}
}
// Date header

View File

@ -77,8 +77,9 @@
<ImageView
android:id="@+id/ivAvatar"
android:layout_width="0dp"
android:layout_height="48dp"
android:padding="6dp"
android:layout_height="0dp"
android:paddingStart="6dp"
android:paddingEnd="6dp"
android:src="@drawable/baseline_person_24"
app:layout_constraintBottom_toBottomOf="@+id/tvFolder"
app:layout_constraintDimensionRatio="1:1"