1

Good morning,

I try to explain my scenario: there is an Activity with a background image representing a person who is speaking. I have to place my TextView exactly over the callout, so it seems that the person is speaking. Below of the TextView I have to put two buttons that allow to go to the previous message or to the main menu. How can I do this with a RelativeLayout? What happens when the activity is displayed by a device with a screen resolution different from the one that I used to debug the application?

Thanks, Nicola

Nicola
  • 11
  • 1
  • can you post what you have done so far? You have to set the relativelayout at runtime based on the screen resolution of the device. – Smogger Oct 21 '13 at 08:40

2 Answers2

0

simply use android:layout_alignLeft="@id/yourtextID and android:layout_alignRight="@id/yourTextID for your left and right Button that you are using. I wrote an example that I think may help you:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    android:id="@+id/rlText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/tvText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Something that he said .." />
</RelativeLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@id/rlText" >

    <Button
        android:id="@+id/bRight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Right" />
</LinearLayout>

    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@id/rlText" >

    <Button
        android:id="@+id/bLeft"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Left" />
</LinearLayout>

Majid Daeinejad
  • 1,037
  • 8
  • 19
-1

Simply use this To Set BackGround Image to your relative Layout

RelativeLayout layout = (RelativeLayout)findViewById(R.id.Your_ID);
int resid=R.drawable.your_background_image;
layout.setBackgroundResource(resid);

For TextView Position use: android:layout_gravity,android:gravity

i hope this will help you...

gsk_sarath
  • 15
  • 6