Java method for android:layout_gravity

Posted by André Leitão on Stack Overflow See other posts from Stack Overflow or by André Leitão
Published on 2010-05-31T18:27:24Z Indexed on 2010/05/31 18:33 UTC
Read the original article Hit count: 686

Filed under:
|
|

Hi folks,

I would like to know if is there a way to call android:layout_gravity property from a java method. I didn't found any method in Android documentation to do it. This is the picture of the layout I want to implement:

alt text

I know to do it through xml, as following:

<FrameLayout
    xlmns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

      <Button
         android:layout_gravity="left|center_vertical"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="<" />


      <Button
         android:layout_gravity="right|center_vertical"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text=">" />
</FrameLayout>

But in my situation, I need to do it through Java code, because I'll implement another layout views dinamically. To avoid merging xml layout with Java code, I would prefer make all layout using Java.

Can you help me?

Thanks.

André Leitão

© Stack Overflow or respective owner

Related posts about java

Related posts about android