Why doesn't my table have equal column widths? Here's the complete layout: first the table, then two buttons in a LinearLayout outside of table, those are divided equally.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp" >
<TableRow
android:layout_marginTop="2dp"
android:gravity="center_vertical" >
<TextView
style="#style/Label.Plain"
android:layout_width="match_parent"
android:text="#string/Caption" />
<EditText
android:background="#00ff00"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="#dimen/button_height"
android:inputType="numberDecimal"
android:selectAllOnFocus="true"
android:textSize="#dimen/spinner_text" />
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="3dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:id="#+id/btnOk"
style="#style/Button.Plain.Fill"
android:layout_weight="1"
android:text="#string/ALS_OK" />
<Button
android:id="#+id/btnClose"
style="#style/Button.Plain.Fill"
android:layout_weight="1"
android:text="#string/CANCEL" />
</LinearLayout>
</LinearLayout>
</ScrollView>
And here's how it looks (one column painted for visibility):
I could use linear layout here, just want to understand the logic behind TableLayout.
you can acquire this in different ways,
like using
android:stretchColumns="*"
in TableLayout or
android:weightSum="1"
in TableRow and
android:layout_width="0dp"
android:layout_height="wrap_content"
in and any views in TableRow.
here is an example
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:id="#+id/tblTop10List"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_marginTop="23dp"
android:stretchColumns="*" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1" >
<TextView
android:id="#+id/tvTopName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:text="HELLO THERE"
android:textColor="#FFF000"
android:layout_column="0"
/>
<TextView
android:id="#+id/tvTopNumber"
android:paddingLeft="4dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#FFF000"
android:text="HELLO THERE "
android:layout_column="1"
/>
</TableRow>
</TableLayout>
</LinearLayout>
** for more info about table layout and it's property please check this nice article
http://www.informit.com/articles/article.aspx?p=2007353&seqNum=7
Related
I'm doing an app that have a tiled UI. I have a problem because I'm using an table layout with 2 table rows inside of it, but, I need to shrink the first row a little bit but I've already tried using padding and margins (android:paddingBottom & android:layout_marginBottom) but I don't get how to shrink the first row to do what I want to do. I attached 2 images that explain better what I want to do, the first one is what I got with the code that I put in here. The second explains better what I want to do.
I have to do a responsive UI so I nor thought to use a fixed android:layout_height.
This is what I have:
This is what I want to do:
<?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="#android:color/white" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/camera"
android:gravity="top|center_horizontal"
android:onClick="camera" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/gallery"
android:gravity="top|center_horizontal"
android:onClick="gallery" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="#+id/button3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/bank_bbva"
android:gravity="top" />
</TableRow>
</TableLayout>
Why not to try this with layouts?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="0.5"
android:background="#drawable/camera"
android:gravity="top|center_horizontal"
android:onClick="camera" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="0.5"
android:background="#drawable/gallery"
android:gravity="top|center_horizontal"
android:onClick="gallery" />
</LinearLayout>
<Button
android:id="#+id/button3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/bank_bbva"
android:gravity="top" />
</LinearLayout>
// try this way,hope this will help you...
<?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="#android:color/white" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/camera"
android:onClick="camera" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#drawable/gallery"
android:onClick="gallery" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bank_bbva"/>
</TableRow>
</TableLayout>
I'm new android. I have a little bit stack in designing layout for Android. In my scenario, I have two button with Linear Layout. Here my xml.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#color/isp_home_color"
>
<Button
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_weight="1"
android:text="#string/sync_text"
android:background="#color/sync_text_color"
android:id="#+id/btn_syncpin"
android:layout_gravity="left"
android:textStyle="bold"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="70dp"
android:text="#string/topup_text"
android:background="#color/topup_text_color"
android:id="#+id/btn_topup"
android:layout_gravity="right"
android:textStyle="bold"/>
<!--Table Layout will come here -->
</LinearLayout>
Here image for this.
When I add new TableLayout inside Linear Layout. I got this.
Here my xml for Table Layout.
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</TableLayout>
Actually, I don't want like this. I want two button as shown in first image. Then, next table layout will occur under this two button. Please help me how can I do this layout. Please pointing to me how to make this. Thanks with advanced.
Give orientation as vertical to the LinearLayout not the TableLayout.Put Two buttons in a LinearLayout with orizontal orientation and give orientation "vertical" for the parent LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#456789"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal">
<Button
android:id="#+id/btn_syncpin"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_gravity="left"
android:layout_weight="1"
android:background="#123456"
android:text="tring/"
android:textStyle="bold" />
<Button
android:id="#+id/btn_topup"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_gravity="right"
android:layout_weight="1"
android:background="#978969"
android:text="topup_text"
android:textStyle="bold" />
</LinearLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF" >
</TableLayout>
</LinearLayout>
Check this out, I just checked it on my Machine and it works as desired, although the background preference and the display strings have been removed.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_syncpin"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_gravity="left"
android:layout_weight="1"
android:textStyle="bold" />
<Button
android:id="#+id/btn_topup"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_gravity="right"
android:layout_weight="1"
android:textStyle="bold" />
</LinearLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/linearLayout2">
</TableLayout>
</RelativeLayout>
take Relative Layout as a parent layout.
Following is an example. it will display your buttons and table layout too
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/isp_home_color"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_syncpin"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_gravity="left"
android:layout_weight="1"
android:background="#color/sync_text_color"
android:text="#string/sync_text"
android:textStyle="bold" />
<Button
android:id="#+id/btn_topup"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_gravity="right"
android:layout_weight="1"
android:background="#color/topup_text_color"
android:text="#string/topup_text"
android:textStyle="bold" />
</LinearLayout>
<TableLayout
android:id="#+id/table"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/linearLayout2" >
</TableLayout>
</RelativeLayout>
thanks
This answer tells only implementation of button_bar_layout for all android versions with buttons at the bottom/top of an activity which look like AlertDialog with OK/Cancel buttons.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="?android:attr/listDivider"
android:orientation="vertical"
android:showDividers="middle" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:divider="?android:attr/listDivider"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:showDividers="middle" >
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:drawable/list_selector_background"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:text="One" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:drawable/list_selector_background"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:text="Two" />
</LinearLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF" >
</TableLayout>
</LinearLayout>
Credits: Who else ? Johnkil
// try this way here i gave you alternative to achieve your requirement from give all of above
1. header.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#color/isp_home_color">
<Button
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_weight="1"
android:text="#string/sync_text"
android:background="#color/sync_text_color"
android:id="#+id/btn_syncpin"
android:textStyle="bold"/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="70dp"
android:text="#string/topup_text"
android:background="#color/topup_text_color"
android:id="#+id/btn_topup"
android:textStyle="bold"/>
</LinearLayout>
2.main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
android:orientation="vertical">
<include
layout="#layout/header"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_weight="1">
</TableLayout>
</LinearLayout>
I have a layout like this....
<?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="fill_parent" >
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Number of payrates (overtime etc)"
android:textSize="12sp" />
<Spinner
android:id="#+id/num_rate"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:textSize="12sp" />
</TableRow>
<TableRow>
<Button
android:id="#+id/cont"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Continue"
android:layout_gravity="bottom|right"/>
</TableRow>
</TableLayout>
Problem is that is still looks like this...
Meaning the button is conforming to the same amount of rows as above. Is there anyway (without switching layout types) to make it fill the entire row?
Also bonus points if you can point me towards how to move the button to the bottom of the screen.
// try this
<?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" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Number of payrates (overtime etc)"
android:textSize="12sp" />
<Spinner
android:id="#+id/num_rate"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textSize="12sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom">
<Button
android:id="#+id/cont"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Continue"/>
</TableRow>
</TableLayout>
For row to fill entire row and to align your button to the bottom use Linear Layout instead of TableRow and give layout_gravity = "bottom".
Try the following data
<?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" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Number of payrates (overtime etc)"
android:textSize="12sp" />
<Spinner
android:id="#+id/num_rate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:textSize="12sp" />
</TableRow>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >
<Button
android:id="#+id/cont"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="Continue" />
</LinearLayout>
</TableLayout>
Hope this works
This is my layout and i want to add table row in to table layout by coding.
layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/bgblack"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/bgblack"
android:orientation="vertical" >
<TextView
android:id="#+id/section_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1"
android:background="#color/Grey"
android:padding="2dp"
android:text="#string/section_phone"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/white"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/detail_phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/section_phone" >
<TableLayout
android:id="#+id/list_phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TableLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
tablerow.xml
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/details"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/detail_phone_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/Blue" />
<TextView
android:id="#+id/detail_phone_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="#drawable/ic_contact_call"
android:padding="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</LinearLayout>
</TableRow>
but when i see output table row is not coming in full width. it is coming with only wrap content.
Output
So can you help me to make output in full screen?
Stretching selected column will fix your problem. See this link. TableLayout.html#attr_android:stretchColumns
<!-- The zero-based index of the columns to stretch. -->
<TableLayout
android:id="#+id/list_phone"
android:stretchColumns="0"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TableLayout>
Wanna to split a screen for my app with two LinearLayouts. What parameters should I use to make exact splitting in two equal parts - first LinearLayout on the top and the second one is just under it.
Use the layout_weight attribute. The layout will roughly look like this:
<LinearLayout android:orientation="horizontal"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout
android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="0dp"/>
<LinearLayout
android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="0dp"/>
</LinearLayout>
I am answering this question after 4-5 years but best practices to do this as below
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:id="#+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/secondView"
android:orientation="vertical"></LinearLayout>
<View
android:id="#+id/secondView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true" />
<LinearLayout
android:id="#+id/thirdLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/secondView"
android:orientation="vertical"></LinearLayout>
</RelativeLayout>
This is right approach as use of layout_weight is always heavy for UI operations.
Splitting Layout equally using LinearLayout is not good practice
Just putting it out there:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"
android:weightSum="4"
android:padding="5dp"> <!-- to show what the parent is -->
<LinearLayout
android:background="#0000FF"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="2" />
<LinearLayout
android:background="#00FF00"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1" />
</LinearLayout>
In order to split the ui into two equal parts you can use weightSum of 2 in the parent LinearLayout and assign layout_weight of 1 to each as shown below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
To Split a layout to equal parts
Use Layout Weights. Keep in mind that it is important to set layout_width as 0dp on children to make it work as intended.
on parent layout:
Set weightSum of parent Layout as 1 (android:weightSum="1")
on the child layout:
Set layout_width as 0dp (android:layout_width="0dp")
Set layout_weight as 0.5 [half of weight sum fr equal two] (android:layout_weight="0.5")
To split layout to three equal parts:
parent: weightSum 3
child: layout_weight: 1
To split layout to four equal parts:
parent: weightSum 1
child: layout_weight: 0.25
To split layout to n equal parts:
parent: weightSum n
child: layout_weight: 1
Below is an example layout for splitting layout to two equal parts.
<LinearLayout
android:id="#+id/layout_top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="vertical">
<TextView .. />
<EditText .../>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="vertical">
<TextView ../>
<EditText ../>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_marginTop="16dp"
android:textSize="18sp"
android:textStyle="bold"
android:padding="4dp"
android:textColor="#EA80FC"
android:fontFamily="sans-serif-medium"
android:text="#string/team_a"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/team_a_score"
android:text="#string/_0"
android:textSize="56sp"
android:padding="4dp"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/team_a_fouls"
android:text="#string/fouls"
android:padding="4dp"
android:textSize="26sp"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:text="#string/_1_points"
android:layout_width="match_parent"
android:onClick="addOnePointTeamA"
android:textColor="#fff"
android:layout_margin="6dp"
android:layout_height="wrap_content" />
<Button
android:text="#string/_2_points"
android:textColor="#fff"
android:onClick="addTwoPointTeamA"
android:layout_width="match_parent"
android:layout_margin="6dp"
android:layout_height="wrap_content" />
<Button
android:text="#string/_3_points"
android:textColor="#fff"
android:onClick="addThreePointTeamA"
android:layout_margin="6dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:text="#string/_1_point_foul"
android:textColor="#fff"
android:layout_width="match_parent"
android:onClick="addOnePointFoulTeamA"
android:layout_margin="6dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:text="#string/team_b"
android:textColor="#EA80FC"
android:textStyle="bold"
android:padding="4dp"
android:layout_marginTop="16dp"
android:fontFamily="sans-serif-medium"
android:textSize="18sp"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/team_b_score"
android:text="0"
android:padding="4dp"
android:textSize="56sp"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/team_b_fouls"
android:text="Fouls"
android:padding="4dp"
android:textSize="26sp"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:text="#string/_1_points"
android:textColor="#fff"
android:fontFamily="sans-serif-medium"
android:layout_width="match_parent"
android:onClick="addOnePointTeamB"
android:layout_margin="6dp"
android:layout_height="wrap_content" />
<Button
android:text="#string/_2_points"
android:layout_margin="6dp"
android:fontFamily="sans-serif-medium"
android:textColor="#fff"
android:onClick="addTwoPointTeamB"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:text="#string/_3_points"
android:fontFamily="sans-serif-medium"
android:textColor="#fff"
android:onClick="addThreePointTeamB"
android:layout_margin="6dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:text="#string/_1_point_foul"
android:textColor="#fff"
android:onClick="addOnePointFoulTeamB"
android:layout_width="match_parent"
android:layout_margin="6dp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<Button
android:text="#string/reset"
android:layout_marginBottom="25dp"
android:onClick="resetScore"
android:textColor="#fff"
android:fontFamily="sans-serif-medium"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>