XML的多行文本视图?

编程入门 行业动态 更新时间:2024-10-09 05:24:59
本文介绍了XML的多行文本视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好我尝试使用textview1和textview1的多行。你可以帮我吗。

<?xml version = 1.0 encoding = utf-8>?; < LinearLayout android:id = @ + id / widget32 android:layout_width = fill_parent android:layout_height = fill_parent android:orientation = vertical xmlns:android = schemas.android/apk/res/android\"> < TextView android:id = @ + id / widget48 android:layout_width = wrap_content android:layout_height = wrap_content android:text = 黄色: /> < LinearLayout android:id = @ + id / widget50 android:layout_width = fill_parent android:layout_height = wrap_content android:orientation = vertical> < TextView android:id = @ + id / textview1 android:layout_width = fill_parent android:layout_height = wrap_content android:text = TextView android:textSize = 18sp android:textColor = #ba1a1a /> < / LinearLayout> < TextView android:id = @ + id / widget49 android:layout_width = wrap_content android:layout_height = wrap_content android:text = 蓝色: /> < LinearLayout android:id = @ + id / widget51 android:layout_width = wrap_content android:layout_height = wrap_content android:orientation = vertical> < TextView android:id = @ + id / textview2 android:layout_width = fill_parent android:layout_height = wrap_content android:text = TextView android:textSize = 18sp android:textColor = #219f0e /> < / LinearLayout> < / LinearLayout>

我尝试过: 我尝试每个组合(fill_parent,wrap_content和android:inputType =textMultiLine)。

解决方案

根据文档,它由 android:inputType 和值 textMultiline 表示,但此属性的类型是位图,所以您可以将不同的值组合在一起,如文档中所示: TextView | Android开发者。 您提及的其他属性与多行选项本身没有直接关系。 由于您未在代码示例中显示 inputType 的使用,因此您不清楚您准确写了什么。问题是:你真的尝试输入多行文字吗?如果您没有使控件可编辑,但尝试使用多行选项,则可以使用多行但不可观察,只是因为有一种方法可以输入多行(使用Enter键)。在这种情况下, text 属性可以有多行;它的值也可以在运行时以编程方式修改,这不需要输入方法和可编辑的控件实例。但问题是:您从不在XML中使用多行,也从不显示任何可能进入多行的其他代码。如果在字符串中至少使用一个新行分隔符,则字符串可以在行中分开: Newline - Wikipedia,免费百科全书。 如你所见,不幸的是,这个分隔符依赖于平台;因为Android是一种Linux,分隔符是LF。在XML中,行分隔符保留在文本节点中,但在属性中,您必须使用字符实体;例如, android:text =first line&#x0A; second line。
-SA

Hi I try to multiline for textview1 and textview1. Could you please help me.

<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/widget32" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" xmlns:android="schemas.android/apk/res/android"> <TextView android:id="@+id/widget48" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Yellow :" /> <LinearLayout android:id="@+id/widget50" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/textview1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="TextView" android:textSize="18sp" android:textColor="#ba1a1a"/> </LinearLayout> <TextView android:id="@+id/widget49" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Blue :" /> <LinearLayout android:id="@+id/widget51" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/textview2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="TextView" android:textSize="18sp" android:textColor="#219f0e"/> </LinearLayout> </LinearLayout>

What I have tried: I try to every combination (fill_parent, wrap_content and android:inputType="textMultiLine").

解决方案

According to the documentation, it's indicated by android:inputType and the value textMultiline, but the type of this property is a bit map, so you can OR together different value, as it's shown in documentation: TextView | Android Developers. Other properties you mention are not directly related to the multiline option itself. As you did not show the use of inputType in your code sample, is not clear what did you write exactly. The question is: did you really try to enter multiline text? If you did not make the control editable, but tried to use the multiline option, multiple lines could be available, but not observable, simply because there is a way to enter several lines (with Enter key). In this case, the text property can have more than one lines; its value can also be modified programmatically during runtime, which would not require an input method and editable control instance. But the problem is: you never use multiple line in your XML and never show any other code which could enter multiple lines. A string can be separate in lines if you use at least one new line separator in the string: Newline — Wikipedia, the free encyclopedia. As you can see, this separator is platform-dependent, unfortunately; as Android is a sort of Linux, the separator is LF. In XML, line separators are preserved in the text nodes, but in attribute you have to use a character entity; for example, android:text="first line&#x0A;second line".
—SA

更多推荐

XML的多行文本视图?

本文发布于:2023-11-23 00:57:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619536.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!