- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想知道如何让 TextView
在多行中显示其内容 without hardcoding the width in the XML .
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:text="Long multiline text"/>
<TextView
android:textColor="@color/text_color"
android:layout_width="130dp"
android:layout_height="wrap_content"
/>
</LinearLayout>
欢迎任何想法。
编辑:我的问题是,当文本超过设置的宽度时(因为它到达了屏幕的末尾),一部分文本就不会显示。我希望文本分成两行
最佳答案
虽然我无法重现不环绕的问题,但您可以通过在第一个 TextView
上使用 weight
来解决定位问题。使用以下 XML 在 Eclipse 的图形布局 View 中提供预期的输出:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:singleLine="false"
android:text="Long multiline text"/>
<TextView
android:textColor="@color/text_color"
android:layout_width="130dp"
android:layout_height="wrap_content"
/>
</LinearLayout>
关于android - 宽度为 "wrap_content"的多行 TextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15258522/
我有带有 TextView 和 Button 的 LinearLayout。我将 layout_height 属性设置为 wrap_content 但 layout_height 的尺寸要大得多。如果
所以我知道当我不使用 Modifier.height() 就像设置了“WRAP_CONTENT”,但是如果我想将高度的值设置为 WRAP_CONTENT。有没有办法做到这一点? 已经尝试过 Instr
我制作了一个测验应用程序,但我遇到了单选按钮的问题。我创建了一个圆形背景并将其设置为我的单选按钮背景。但是,背景不会随着单选按钮内的文本量而放大。 这是一张图片 我无法发布信誉度低于 10 的图片。
我的理解是 wrap_content 占用的空间与其内容所需的空间一样多。但这不也适用于 TextView 吗? 在下面的布局中,为什么当我将 ID 为 real_status 的 TextView
目前我在另一个 View 中有一个 View (它是一个广告),但是因为我使用的是 MATCH_PARENT,所以宽度是整个屏幕的长度,而我只希望它是广告尺寸。现在 WRAP_CONTENT 解决了这
我想要实现的是 XML(请不要编写代码!!!)来执行此操作: 我不想要下面的 xml,因为它会将我的弹出窗口拖到屏幕顶部 这是我的 XML,但它也不起作用 :( 最佳答案 如果您有
我正在使用自定义布局来显示对话框。这是布局:
大家好,感谢您的帮助。 我在 Android Studio 中有一个项目。 我在垂直 LinearLayout 中使用 ImageView。 这是我的参数; 你可以在下面看到我的图像(红色 bloc
我对 FrameLayout 有疑问。我想创建 FrameLayout,它将具有第一个 child 的高度,第二个 child 将获得父级的高度(本例中为 100dp)。但我得到的是 FrameLay
当 RecyclerView 的 layout_width 为 wrap_content 时,我试图将其居中,但没有成功 当 RecyclerView 被赋予任何确定的 layout_w
我创建了一个自定义背景图片,并想将其用作高度为 wrap_content 的布局的背景。但是,该布局中内容的总高度远小于背景图像的高度。 当我通过 android:background="@drawa
有一个 TableLayout,它有一堆看起来像这样的行: 当前的行为是,如果第一个按钮的文本换行到第二行,按钮的高度会更大。这很好。然而,另一个按钮,如果它没有那么多文本
我正在尝试使用 wrap_content 让我的 Recycler View 在只有几个项目时不占用所有屏幕空间,但这似乎不起作用。有什么问题? 代码: 最
我正在尝试布局一个应该包装其内容的 View ,但它不应比其父宽度小约 100dp。如何使用 RelativeLayout 或其他布局来做到这一点?我现在所拥有的总是会使 View 比其父 View
“wrap_content”在我的按钮中不起作用,它目前看起来像这样: now want ____________ | |
为什么 RelativeLayout 不换行内容?如果我删除最后一个与底部父级对齐的 View ,它就可以工作...
WRAP_CONTENT 应该这样做: Special value for the height or width requested by a View. WRAP_CONTENT means th
我想创建一个 ViewPager,其宽度环绕其内容,并在其父项中水平居中。第一个代码 fragment 使用 LinearLayout 来创建此效果,如第一个屏幕截图所示。第二个代码 fragment
我正在尝试制作我的 ListView 的行,以便单击任何一行都会在适当的位置展开该行并显示额外的选项。我使用行布局(称为 rowView)包含的额外布局(我们称之为 expandView),高度最初设
我试图让 RelativeLayout 包装它的内容高度和宽度。它似乎在宽度上做得很好,但高度不环绕。它覆盖了整个屏幕。有人知道为什么吗?
我是一名优秀的程序员,十分优秀!