tags:

views:

150

answers:

1

Hi,

I've prepared custom component based on LinearLayout. Whole component is defined in XML. Currently to use it you have to write:

<com.xxx.android.components.TopMenu 
    android:layout_width="fill_parent"
    android:layout_height="44dp"
/>

Is it possible to set width and height in the java constructor? So it would be possible to write just:

<com.xxx.android.components.TopMenu />

I've tried to modify and set LayoutParams, but it didn't work for me.

+1  A: 

Not in the constructor, but in the onFinishInflate() callback to your custom widget, I this might work.

CommonsWare
Thanks! It works fine!
Michal Dymel