Setting Layout parameters in android

Viewed 33299

Working with the XML file was easy as I could specify the parameters as

<android:layout_width="fill_parent" android:layout_height="wrap_content">

But I am confused while specifying it through code. For each view I specify the parameters using

view.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT)); 

I see that I have an option of specifying it as relative layout, frame layout etc. As of now I am using linear layout for all views such as images, text and also gridview. Should the view parameters be defined based on the layout of the parent element? Or is it OK to specify it as linear layout even if the view is a child of, say, a framelayout? Sorry, but I couldn't find out the difference.

2 Answers
Related