Sur*_*gch 14 android margins leadingmarginspan2 staticlayout
领先保证金的含义是什么?
文件LeadingMarginSpan 说
影响前导边距的段落样式.单个段落可以有多个主要边距跨度; 它们将按顺序呈现,每个都将其边距添加到它之前的边距.右边到左边的段落中的前导边距位于右边.
但它并没有真正说明领先优势是什么.
它是否像段落第一行的制表符缩进?或者它是整个段落缩进的地方?我认为它是/lidɪŋ/而不是/lɛdɪŋ/就像在行之间的空间一样.
我想知道的原因是我正在尝试使用StaticLayout创建自己的TextView.我指的是想法的Layout和StaticLayout 源代码.我试图删除所有不必要的部分,但我不知道这是什么.
以下是一些SO问题,也询问领先优势,但问题似乎知道这意味着什么.
图像确实很有用,但并非绝对必要.
Sur*_*gch 19
前导边距指的是段落缩进多少,包括第一行和后续行.
以下示例应该使一切都清楚.下面示例中的TextView包含两段文本(即,它们包括\n字符).
以下是使用的样板代码:
LeadingMarginSpan span = ... // substitute this line with the examples below
TextView textView = (TextView) findViewById(R.id.textView) ;
SpannableString spannableString = new SpannableString("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\nDuis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
spannableString.setSpan(span, 0, spannableString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(spannableString);
Run Code Online (Sandbox Code Playgroud)
有两个主要的构造函数.
第一个构造函数: LeadingMarginSpan.Standard(int first, int rest)
first 告诉每个段落的第一行缩进多少像素. rest 告诉每个段落的其余行缩进多少像素.左侧的示例将第一行缩进20像素,其余行缩进100像素.(没有添加填充TextView.)
LeadingMarginSpan span = new LeadingMarginSpan.Standard(20, 100); // left example
Run Code Online (Sandbox Code Playgroud)
右边的示例显示第一行缩进100,其余行根本没有缩进.
LeadingMarginSpan span = new LeadingMarginSpan.Standard(100, 0); // right exmaple
Run Code Online (Sandbox Code Playgroud)
第二个构造函数: LeadingMarginSpan.Standard(int every)
every 告诉每个段落的每一行缩进多少像素.此示例将每行缩进200像素.
LeadingMarginSpan span = new LeadingMarginSpan.Standard(200);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2274 次 |
| 最近记录: |