【问题标题】:TextView array broken into linesTextView 数组分成几行
【发布时间】:2012-09-30 13:28:22
【问题描述】:

我已将 TextView 动态添加到 LinearLayout 中。 问题是,如果 TextViews 的文本比布局宽度长,它们会显示错误。 有什么方法可以使 TextViews 匹配布局宽度并从新行开始?

【问题讨论】:

标签: android arrays textview


【解决方案1】:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

</LinearLayout>

使用 LinearLayout.LayoutParams

params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
txtView.setLayoutParams(params);
layout.addView(txtView);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多