Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
now hopefully fixing header/subtitle extra sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
sk22 committed Oct 18, 2023
1 parent 5840c94 commit b8dccbb
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public HeaderSubtitleLinearLayout(Context context, AttributeSet attrs, int defSt
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
if(getLayoutChildCount()>1){
int remainingWidth=MeasureSpec.getSize(widthMeasureSpec);
int fullWidth=MeasureSpec.getSize(widthMeasureSpec);
int remainingWidth=fullWidth;
for(int i=1;i<getChildCount();i++){
View v=getChildAt(i);
if(v.getVisibility()==GONE)
Expand All @@ -36,12 +37,9 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
LayoutParams lp=(LayoutParams) v.getLayoutParams();
remainingWidth-=v.getMeasuredWidth()+lp.leftMargin+lp.rightMargin;
}
if(getChildAt(0) instanceof TextView first){
// guaranteeing at least 64sp of width for the display name
first.setMaxWidth(Math.max(remainingWidth, V.sp(64)));
}
if(getChildAt(1) instanceof TextView second){
second.setMaxWidth(Math.max(remainingWidth, V.sp(120)));
View first=getChildAt(0);
if(first instanceof TextView){
((TextView) first).setMaxWidth(Math.max(remainingWidth, fullWidth/2));
}
}else{
View first=getChildAt(0);
Expand Down

0 comments on commit b8dccbb

Please sign in to comment.