gpt4 book ai didi

android - 如何在 TextView 字段中设置永久文本?

转载 作者:行者123 更新时间:2023-11-30 00:02:56 26 4
gpt4 key购买 nike

有一个名为“A”的按钮没有任何重力。所以A在左边。我想在此按钮的中心设置另一个文本而不更改字符串“A”及其位置?我该怎么做?

对不起我的英语希望你能理解。

最佳答案

我认为你不能在一个按钮内做到这一点,但你可以制作一个看起来像 ButtonRelativeLayout,然后设置不同的 TextView 用于不同的字符。

在那种情况下你的代码应该是这样的

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="New Text" />
</RelativeLayout>

您还可以创建一个选择器并将其应用于 RelativeLayout 以实现按钮的效果。按照此 https://stackoverflow.com/a/14024007/3789993

希望对你有帮助

关于android - 如何在 TextView 字段中设置永久文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49556276/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com