views:

211

answers:

2

Hi,

I have a RelativeLayout defined in xml and I call the setContentView(R.layout.relativeLAyout) for displaying in Activity.

Now, if I want to resize this RelativeLayout then can it be done and if yes, then can someone let me know how?

The inner components can be resized relatively to the parent.

Is this actually possible?

Regards Sunil

A: 

Hi,

Suppose I have an XML file such as A.xml with the following contents

    <TextView
        android:id = "@+id/txtView"
        android:layout_width = "fill_parent"
        android:layout_height = "wrap_content"
        android:text = "New Babble" >
    </TextView>

</RelativeLayout>

This is the xml with just one TextView. It will occupy full screen since its fill_parent for both width and height. The actual layout that I want will have more views than just TextView.

Now, in case I want to resize this RelativeLayout to say 200 * 200 then can be it done. If yes, then how can we do that?

Hope to get a quick response.

Regards Sunil

sunil
I was able to resize the layout with layout.getLayoutParams().height = 200 and similar for width. But again it doesn't resize the inner components of the Layout.
sunil
A: 

As to the inner components not resizing, make sure that both android:layout_width and and android:layout_height are set to fill_parent - then they should take up the space given to the parent.

elmo
I have used fill_parent only, then also will check it once again. Thanks again.
sunil