How to add borders to the columns and rows of a Tablelayout via code:

Asked

Viewed 927 times

0

I created a table, but I need to add rows and columns to the table via code. Does anyone know how I can do this? Thanks in advance.

How I need you to stay: inserir a descrição da imagem aqui

  • Help? http://stackoverflow.com/a/7117665/5524514

1 answer

1

There is no direct way to do this, you will have to work with background, padding and margins.

below an idea of what you can try to work.

      <TableLayout android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:stretchColumns="*" android:background="#ff0000">
        <TableRow android:background="#00ff00" android:layout_margin="2dip">
            <Button android:id="@+id/button" android:text="+" android:background="#0000ff" android:layout_margin="2dip"/>
            <TextView android:text="@string/label"  android:background="#0000ff" android:layout_margin="2dip"/>
            <TextView android:id="@+id/amount"  android:background="#0000ff" android:layout_margin="2dip"/>

</TableRow>

code removed and translated from here

  • Coincidentally, it’s the same link I posted in the comments, the same instant you posted the answer O.o

  • kkkk, truth, what are the odds

  • If you format the code it would be more readable. It’s a way to value your answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.