Right align column in android table layout

前端 未结 2 1726
天命终不由人
天命终不由人 2021-02-18 20:44

I want to draw a table in which last column should be at the right most side of the table.

This is how the table row looks like:



        
相关标签:
2条回答
  • 2021-02-18 21:27
    1. android:stretchColumns="x" where x is the column you want to fill
    2. android:layout_width="fill_parent" to ensure everything fills the screen
    3. android:layout_gravity="right" for the view component in column "x"

    example (pseudo code):

    <TableLayout
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:stretchColumns="1">
    
        <TableRow>
            <TextView android:text="Left Column" />
            <TextView android:layout_gravity="right|center_vertical" android:text="Right Adjusted Column" />
        </TableRow>
    
    </TableLayout>
    
    0 讨论(0)
  • 2021-02-18 21:36

    Here you have to do

    1. set the table row width to fill_parent

    2. and set the android:layout_gravity="right" to the textview which you want to align right it to the table row

      ---- or ----

    1. add the weight to the textview inside a table row so that they can align how you want.
    0 讨论(0)
提交回复
热议问题