I have a TableLayout I would like to change. The layout is three rows big. In the first row and first column there is the article ID.
In the next two rows the article description follows.
To not waste so much space, I would like the article description to start on the first row already, after the article ID.
A-100 = article ID
ABCD = article description
If I add some margin and make the article description span over multiple rows, the margin will apply to all rows.
TextViews
and splitting the text in code?I'm very familiar with android-constraintlayout and have some other texts spanning over multiple lines in the same app. But if I'm not mistaken I would face the same problem. I can't set a margin or padding for the first row/line only.
Is there any other layout type I could use where I just set the margin for the first row and then let the text overflow?
Thanks to Cheticamp's comment, I learned about the LeadingMarginSpan and was able to achieve my layout as desired.
Both TextViews start at the same position horizontally in the layout.xml and then I add a LeadingMarginSpan when setting up my RecyclerView in the ViewHolder:
SpannableString spannableString = new SpannableString(articles[pos].getArticleName());
if (spannableString.length() > 0) {
spannableString.setSpan(new android.text.style.LeadingMarginSpan.Standard(250, 0), 0, 1, 0);
}
holder.artName.setText(spannableString);