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

4

2 回答 2

0

只需将android:layout_alignLeft="@id/yourtextIDandandroid:layout_alignRight="@id/yourTextID用于您正在使用的左右按钮。我写了一个我认为可以帮助你的例子:

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

于 2013-10-21T08:46:39.723 回答
-1

只需使用它来将背景图像设置为您的相对布局

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

对于 TextView 位置使用: android:layout_gravity,android:gravity

我希望这能帮到您...

于 2013-10-21T09:04:38.027 回答