Java 如何在textview中的消息周围添加语音气泡?我可以只使用文本视图启动聊天界面吗?
我是一个相对业余的程序员,一直在逐步学习android编程。 我对现在流行的关于通过信息交换的信息的言论泡沫持怀疑态度 我一直在尝试制作一个聊天界面,经过反复试验,我得出了类似的结论 聊天窗口的代码如下所示: XMLJava 如何在textview中的消息周围添加语音气泡?我可以只使用文本视图启动聊天界面吗?,java,android,textview,Java,Android,Textview,我是一个相对业余的程序员,一直在逐步学习android编程。 我对现在流行的关于通过信息交换的信息的言论泡沫持怀疑态度 我一直在尝试制作一个聊天界面,经过反复试验,我得出了类似的结论 聊天窗口的代码如下所示: XML <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/ranklabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ranklabel" />
<TextView
android:id="@+id/rank"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ranklabel" />
<TextView
android:id="@+id/countrylabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ranklabel"
android:text="@string/countrylabel" />
<TextView
android:id="@+id/country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rank"
android:layout_toRightOf="@+id/countrylabel" />
<TextView
android:id="@+id/populationlabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/countrylabel"
android:text="@string/populationlabel" />
<TextView
android:id="@+id/population"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/country"
android:layout_toRightOf="@+id/populationlabel" />
<EditText
android:id="@+id/reply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/replyMsg"
android:ems="10"
android:hint="Reply to the user here..."
android:inputType="textMultiLine"
android:maxLength="160" />
<Button
android:id="@+id/replyMsg"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/roundbutton"
android:text="GO"
android:textColor="#ffffff"
/>
<TextView
android:id="@+id/msgView"
android:layout_width="400dp"
android:layout_height="200dp"
android:layout_above="@+id/replyMsg"
android:layout_alignParentLeft="true"
android:layout_below="@+id/population"
android:maxLines = "1999"
android:scrollbars = "vertical" />
这是一段代码,用于在文本视图中显示附加了a/n的消息,以显示在回复窗口中键入的每个句子
我需要您的帮助以允许在聊天窗口中显示消息,而不是像这样:
“>你好”您可以自定义一个可绘制的形状,并将其指定给带有一些角的textView tvBackGround.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorFour" />
<stroke
android:color="@color/colorTwo"
android:width="2dp" />
<corners
android:bottomLeftRadius="4dp"
android:bottomRightRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp" />
代码应该进入
onCreate()
。如果您在活动上运行此命令,然后进入onCreateView()
,如果您在片段上运行此命令感谢您的快速回复,设置的背景是否应进入我的void onClick?还是关于虚空的一吻?此外,每条消息是否会显示一个气泡?如果您想将其设置为始终使用背景,只需在主xml中执行即可:android:background=“@drawable/tvBackGround”不,不,我的意思是命令“msgView.setBackground(R.drawable.tvBackGround)”,它是否应该进入我的公共void onClick?或者我应该在“msgView.setMovementMethod(new ScrollingMovementMethod())”下面键入它吗
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorFour" />
<stroke
android:color="@color/colorTwo"
android:width="2dp" />
<corners
android:bottomLeftRadius="4dp"
android:bottomRightRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp" />
msgView.setBackground(R.drawable.tvBackGround)