belgarion belgarion - 25 days ago 11
Java Question

When passing a message from one activity to the next, that message always appears under anything else I write. How do I make it appear on top?

Temperature is the text that needs to be displayed at the bottom and activity_display_message is the 1337 that needs to be displayed at the top.

Answer

you can try this

use two text view to show your value and "Temperature" text. you can use RelativeLayout to easily manage show temperature text at bottom.

 <?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>

and inside java write

TextView txtTempValue = (TextView)findViewById(R.id.tempValue);
txtTempValue.setText(your_temp_value);
Comments