我想知道Label的texture_size是什么意思。由于以下代码,它让我感到困惑
我的.kv
<MyLayout>:
rows:2
ScrollView:
do_scroll_x: False
do_scroll_y: True
Label:
size_hint_y: None
height: self.texture_size[1]
text_size: self.width, None
padding: 100, 100
text: '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n'*2
虽然阅读了有关纹理的文档,但我不知道为什么我需要使用texture_size设置“高度”以及标签的纹理大小是什么意思。任何人都可以帮助我理解它吗?非常感谢!
来自文档:
文本图像(纹理)仅足够大以包含 字符并位于标签的中心。
texture
包含用于显示的 text
。 texture_size
是 texture
的大小
您不必将
height
设置为 self.texture_size[1]
。这会将高度设置为足够大以包含 texture
。