Adding more reliable calculation of label width.
This commit is contained in:
parent
df2bc91e9f
commit
a7213add30
@ -59,6 +59,7 @@ import org.mian.gitnex.clients.RetrofitClient;
|
|||||||
import org.mian.gitnex.fragments.BottomSheetSingleIssueFragment;
|
import org.mian.gitnex.fragments.BottomSheetSingleIssueFragment;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
|
import org.mian.gitnex.helpers.LabelWidthCalculator;
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
import org.mian.gitnex.helpers.TimeHelper;
|
||||||
import org.mian.gitnex.helpers.UserMentions;
|
import org.mian.gitnex.helpers.UserMentions;
|
||||||
import org.mian.gitnex.models.IssueComments;
|
import org.mian.gitnex.models.IssueComments;
|
||||||
@ -451,7 +452,7 @@ public class IssueDetailActivity extends BaseActivity {
|
|||||||
.useFont(Typeface.DEFAULT)
|
.useFont(Typeface.DEFAULT)
|
||||||
.textColor(new ColorInverter().getContrastColor(color))
|
.textColor(new ColorInverter().getContrastColor(color))
|
||||||
.fontSize(30)
|
.fontSize(30)
|
||||||
.width((width * labelName.length()) - ((width / 4) * labelName.length()))
|
.width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, 30, 15))
|
||||||
.height(50)
|
.height(50)
|
||||||
.endConfig()
|
.endConfig()
|
||||||
.buildRoundRect(labelName, color, 10);
|
.buildRoundRect(labelName, color, 10);
|
||||||
|
@ -1,11 +1,28 @@
|
|||||||
package org.mian.gitnex.helpers;
|
package org.mian.gitnex.helpers;
|
||||||
|
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class LabelWidthCalculator {
|
public class LabelWidthCalculator {
|
||||||
|
|
||||||
|
public static int calculateLabelWidth(String text, Typeface typeface, int textSize, int paddingLeftRight) {
|
||||||
|
|
||||||
|
Paint paint = new Paint();
|
||||||
|
Rect rect = new Rect();
|
||||||
|
|
||||||
|
paint.setTextSize(textSize);
|
||||||
|
paint.setTypeface(typeface);
|
||||||
|
paint.getTextBounds(text, 0, text.length(), rect);
|
||||||
|
|
||||||
|
return rect.width() + (paddingLeftRight * 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static int customWidth(int labelLength) {
|
public static int customWidth(int labelLength) {
|
||||||
|
|
||||||
int width = 33;
|
int width = 33;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user