Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ public void setTextSize(float textSizeDp) {
int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE_DP, getResources().getDisplayMetrics());

LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mIvIcon.getLayoutParams();
layoutParams.height = textSize;
layoutParams.width = textSize;
layoutParams.topMargin = textSize / 5;
int padding = dip2px(2);
int paddingRight = padding + dip2px(1);
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.width = textSize + (paddingRight - padding);
layoutParams.setMargins(0,0,0,0);

mIvIcon.setPadding(padding, textSize / 5, paddingRight, 0);
mIvIcon.setLayoutParams(layoutParams);
}

Expand Down Expand Up @@ -129,4 +132,9 @@ public void addViewNoInvalidate(View child) {
}
addViewInLayout(child, -1, params);
}

private int dip2px (float dipValue) {
final float scale = getResources().getDisplayMetrics().density;
return (int) (dipValue * scale + 0.5f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
android:id="@+id/tv_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:layout_marginStart="1dp"
android:gravity="center_vertical"
android:textSize="12sp"
android:visibility="gone"
Expand Down