Sam*_*eer 76 android word-wrap textview
有没有人知道如何在Android平台的TextView中包装文本.即如果textview中的文本超出屏幕长度,则应在第二行显示.
我搜索并尝试了以下内容:
android:scrollHorizontally="false",
android:inputType="textMultiLine",
android:singleLine="false"
Run Code Online (Sandbox Code Playgroud)
但没有工作..
任何人都可以建议我怎么做..我是Android平台相对较新的..
Guy*_*kun 50
对我来说,此问题仅发生在Android <4.0上
我使用的参数组合是:
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
Run Code Online (Sandbox Code Playgroud)
maxLines计数似乎是使我的TextView包装的随机最终部分.
aij*_*aij 31
对于TextView
在a内的情况TableLayout
,解决方案是设置android:shrinkColumns="1"
在TableLayout
.(替换1
为要包装的TextView所在的列号.(0-indexed))
AFAICT,不需要其他属性TextView
.
对于其他情况,请在此处查看其他答案.
FWIW,我最初得到了它的工作
<TextView
android:id="@+id/inventory_text"
android:layout_width="fill_parent"
android:layout_weight="1"
android:width="0dp"
Run Code Online (Sandbox Code Playgroud)
但这导致Dialog底部有一些额外的空白空间.
Bak*_*ker 30
<TextView
android:id="@+id/some_textview"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="@id/textview_above"
app:layout_constraintRight_toLeftOf="@id/button_to_right"/>
Run Code Online (Sandbox Code Playgroud)
android:maxLines="2"
为防止垂直扩展(2只是例如)android:ellipsize="end"
0dp宽度允许左/右约束来确定窗口小部件的宽度.
设置左/右约束设置窗口小部件的实际宽度,文本将在其中包装.
Nir*_*sar 11
使用
app:breakStrategy="simple"
中AppCompatTextView
,它会在控制段落布局。
它有三个常数值
在你的 TextView xml 中设计
<android.support.v7.widget.AppCompatTextView
android:id="@+id/textquestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:scrollHorizontally="false"
android:text="Your Question Display Hear....Your Question Display Hear....Your Question Display Hear....Your Question Display Hear...."
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold"
app:breakStrategy="simple" />
Run Code Online (Sandbox Code Playgroud)
如果您当前的最低 api 级别为 23 或更高,则在编码中
yourtextview.setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE);
Run Code Online (Sandbox Code Playgroud)
有关更多参考,请参阅此BreakStrategy
Kar*_*uez 10
您必须使用2个参数:
android:ellipsize="none"
:文本未在文本视图宽度上剪切
android:scrollHorizontally="false"
文本根据需要包含尽可能多的行
这应该可以解决你的问题:android:layout_weight="1"
.
好吧,伙计们,事实是在中间的某个地方,因为你必须从父母的观点和孩子的角度看问题.下面的解决方案仅适用于微调器模式= dialog
无论Android版本(没有问题......在VD和DesireS中使用Android => 2.2测试它):
.设置微调器(父)模式,如:
android:spinnerMode="dialog"
Run Code Online (Sandbox Code Playgroud)将textview的(子自定义视图)属性设置为:
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
Run Code Online (Sandbox Code Playgroud)我希望这对你也有用.
Lud*_*dry -1
您需要将 TextView 添加到 ScrollView 中,如下所示:
<ScrollView android:id="@+id/SCROLL_VIEW"
android:layout_height="150px"
android:layout_width="fill_parent">
<TextView
android:id="@+id/TEXT_VIEW"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="This text view should act as header This text view should act as header This text view should act as header This text view should act as header This text view should act as header This text view should act as header This text view should act as header" />
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
144539 次 |
最近记录: |