gpt4 book ai didi

android - 以编程方式在 TextView 下画线

转载 作者:行者123 更新时间:2023-11-30 00:53:33 27 4
gpt4 key购买 nike

我有一个动态添加 TextView 循环的布局:

TextView msg = new TextView(this);
TextView Bmsg = new TextView(this);
msg.setText(splittedItem[0]);
msg.setTextColor(0xFF2C85A6);
msg.setTextSize(22);
msg.setPadding(10, 10, 0, 10);
Bmsg.setText("- "+splittedItem[1]);
Bmsg.setPadding(20, 0, 10, 30);
Bmsg.setTextSize(18);
linearLayout.addView(msg);
linearLayout.addView(Bmsg);

我想用这样的一行来划分每个 TextView:

我需要在 Bmsg 下添加一行。我找到了这个 - draw line under TextView on Android ,但我不明白如何以编程方式进行此操作。

在 XML 中:

 <LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/buttonlayout">
</LinearLayout>

最佳答案

使用它并让我知道它是否有效

View view = new View(this);
view.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT,2
));
view.setBackgroundColor(Color.parseColor("#000000"));

linearlayout.addView(view);

关于android - 以编程方式在 TextView 下画线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40554753/

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