I have 2 columns with 10 buttons with a bit longer names and i dont know how to align them.. here is my code.. so please if anyone have an idea how to make it straight? I have 2 columns with 10 buttons with a bit longer names and i dont know how to align them.. here is my code.. so please if anyone have an idea how to make it straight?
`<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/futuratheme"
android:gravity="center"
android:paddingBottom="25dip" >
<TableRow android:id="@+id/tableRow1" >
<Button
android:id="@+id/bPapir"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_marginRight="5dip"
android:layout_weight="50"
android:text="@string/papir" />
<Button
android:id="@+id/bInformaticki"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="15dip"
android:layout_weight="50"
android:text="@string/informaticki" />
</TableRow>
<TableRow android:id="@+id/tableRow5" >
<Button
android:id="@+id/bUredski"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_marginRight="5dip"
android:layout_weight="50"
android:text="@string/uredski" />
<Button
android:id="@+id/bPisaci"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="15dip"
android:layout_weight="50"
android:text="@string/pisaci_pribor" />
</TableRow>
<TableRow android:id="@+id/tableRow4" >
<Button
android:id="@+id/bOdlaganje"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_marginRight="5dip"
android:layout_weight="50"
android:text="@string/odlaganje" />
<Button
android:id="@+id/bPrezentacija"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="15dip"
android:layout_weight="50"
android:text="@string/prezentacija" />
</TableRow>
<TableRow android:id="@+id/tableRow3" >
<Button
android:id="@+id/button5"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_marginRight="5dip"
android:layout_weight="50"
android:text="Button" />
<Button
android:id="@+id/button6"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="15dip"
android:layout_weight="50"
android:text="Button" />
</TableRow>
<TableRow android:id="@+id/tableRow2" >
<Button
android:id="@+id/button3"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_marginRight="5dip"
android:layout_weight="50"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="15dip"
android:layout_weight="50"
android:text="Button" />
</TableRow>
`
Apply this to each tablerow
android:layout_width="fill_parent"
android:layout_height="wrap_content".
Also you may want to add
android:gravity="aGravityType"
(example "left|center", "right|center") to your buttons, that way it will align the text.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.