Java 在将消息从一个活动传递到下一个活动时,该消息始终显示在我编写的任何其他活动下。如何使其显示在顶部?
温度是需要显示在底部的文本,活动显示消息是需要显示在顶部的1337。添加Java 在将消息从一个活动传递到下一个活动时,该消息始终显示在我编写的任何其他活动下。如何使其显示在顶部?,java,android,android-layout,Java,Android,Android Layout,温度是需要显示在底部的文本,活动显示消息是需要显示在顶部的1337。添加TextView并使用TextView.setText(您的\u字符串)在上面。我假设您当前正在尝试在线性布局上打印文本 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://sche
TextView
并使用TextView.setText(您的\u字符串)代码>在上面。我假设您当前正在尝试在线性布局上打印文本
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.myapplication.DisplayMessageActivity">
<TextView
android:id="@+id/activity_display_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/temperature"/>
</LinearLayout>
你可以试试这个
使用两个文本视图显示您的值和“温度”文本。您可以使用RelativeLayout轻松管理底部的“显示温度”文本
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_display_message"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tempValue"
android:textSize="25sp"
android:gravity="center"
android:text="Value"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Temperature"
android:textSize="25sp"
android:gravity="bottom|center"
android:layout_below="@+id/tempValue"/>
</RelativeLayout>
请显示您试图设置温度值的背景(java)代码。该值(温度值)必须位于单词(温度)旁边,因为我还必须显示重量、加速度、速度、温度、高度和压力。但它是有效的,谢谢你!我会尽量让它出现在它旁边。谢谢!我应该在“你的字符串”中写什么?对不起,这里没有总数。这是您要在“温带”上方显示的数字。问题中的“1337”。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_display_message"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tempValue"
android:textSize="25sp"
android:gravity="center"
android:text="Value"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Temperature"
android:textSize="25sp"
android:gravity="bottom|center"
android:layout_below="@+id/tempValue"/>
</RelativeLayout>
TextView txtTempValue = (TextView)findViewById(R.id.tempValue);
txtTempValue.setText(your_temp_value);