Thursday, February 10, 2011

How to change custom component height programatically

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.

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

    Michal Dymel : Thanks! It works fine!

0 comments:

Post a Comment