How can I create a layout with two columns, with one textview on the left side and the other on the right side and gap in the middle?. I have already seen the answer here Android: creating two columns in a linearlayout. But I need a certain space between the two columns. Please somebody help.
Using the answer you're pointing, you have to add a view in the middle, with 0dp in width but with a weight of 0.1, 0.2, whatever, depending on your gap.
If I understood correctly, you want to have two columns of identical width with a space in-between them. Is so:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- First column -->
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My Column 1 Text"/>
</LinearLayout>
<!-- Space in-between -->
<Space
android:layout_width="25dp"
android:layout_height="match_parent" />
<!-- Second column-->
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My Column 2 Text"/>
</LinearLayout>
</LinearLayout>
Creating two columns in a linearlayout with a gap in the middle
You can use View for gap between two LinearLayout
Try this
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="#88FF0000">
<TextView
android:layout_width="match_parent"
android:text="Nilesh"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:layout_width="10dp"
android:background="#color/colorPrimary"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="#88FF0000">
<TextView
android:layout_width="match_parent"
android:text="Nilesh"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
OUTPUT
You can add a View at the center:
<LinearLayout
android:layout_margin="30dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_weight="1"
android:background="#color/colorPrimary"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<View
android:layout_width="8dp"
android:background="#android:color/white"
android:layout_height="match_parent" >
</View>
<EditText
android:layout_weight="1"
android:background="#color/colorPrimary"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
I would put some margin on each column so you can control the space in between. For me is the easiest way to do it.
<LinearLayout android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="#+id/linearLayout2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="left"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginEnd="25dp">
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Street"
android:background="#88FF0000"/>
</LinearLayout>
<LinearLayout android:id="#+id/linearLayout3"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginStart="25dp">
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="456546546"
android:layout_gravity="right"
android:background="#8800FF00"/>
</LinearLayout>
</LinearLayout>
Related
My layout is like this
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/searchKey"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="xx" />
<ScrollView
android:layout_weight="1"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/search_results"
android:textSize="#dimen/text_font_size"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_gravity="center|bottom"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/lastCharacterButton"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lastChar_btn" />
<Button
android:id="#+id/nextCharacterButton"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/nextChar_btn" />
</LinearLayout>
</LinearLayout>
However, when there are little or no text, the buttons are pulled up, when there are too many text in search_results TextView, the buttons won't show up because scrollview takes the space all the way to the bottom. Any suggestion to always keep the buttons at the bottom and always visible?
First of all you have to set the ScrollView's height to 0dp.
<ScrollView
android:layout_weight="1"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="0dp">
<TextView
android:id="#+id/search_results"
android:textSize="#dimen/text_font_size"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</ScrollView>
You have to do this because the weight param is going to control the size of the view depending on how much space is available. If you set it to wrap content, it will take how much space it needs to wrap everything within.
Then you need to remove your LinearLayout's weight param:
<LinearLayout
android:orientation="horizontal"
android:layout_gravity="center|bottom"
android:id="#+id/LL1"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/lastCharacterButton"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last_Char" />
<Button
android:id="#+id/nextCharacterButton"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="next_char" />
</LinearLayout>
And the reason for doing that is just the opposite of the previous explanation: in this case the wrap content is going to take the space necessary to always display the buttons within.
Here is some sample code I put together for you. You basically need to take out the linear layout you have wrapping you xml layout and use a relative layout instead. Once you do that you can add ids to the linear layout with the buttons and then have the edit text align to the parent top. Then you can put the scrollview below the edittext and then put the scrollview above to the linear layout containing the buttons. This should work!
<?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"
tools:context="com.example.thegamefan93.loginregister.LoginActivity">
<EditText
android:id="#+id/searchKey"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:hint="xx" />
<ScrollView
android:layout_weight="1"
android:fillViewport="true"
android:layout_below="#id/searchKey"
android:layout_width="match_parent"
android:layout_above="#+id/LL1"
android:layout_height="wrap_content">
<TextView
android:id="#+id/search_results"
android:textSize="20sp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_gravity="center|bottom"
android:layout_weight="1"
android:id="#+id/LL1"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/lastCharacterButton"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last_Char" />
<Button
android:id="#+id/nextCharacterButton"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="next_char" />
</LinearLayout>
</RelativeLayout>
Try this,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="#+id/searchKey"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:hint="xx" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/linear"
android:layout_below="#+id/searchKey"
android:layout_weight="1"
android:fillViewport="true">
<TextView
android:id="#+id/search_results"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textSize="#dimen/text_font_size" />
</ScrollView>
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="#+id/lastCharacterButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/lastChar_btn" />
<Button
android:id="#+id/nextCharacterButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/nextChar_btn" />
</LinearLayout>
</RelativeLayout>
I have a linear layout with two listviews, a text view, and another linear layout to hold some buttons. I want the second listview to be twice the height of the first. I have set the height of both list views to 0dp and gave the first a layout_weight of 1 and the second a weight of 2, and then set the weightSum of the containing view to 3. Here is the actual layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:weightSum="3"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/categoryList" />
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:id="#+id/itemList" />
<TextView
android:id="#+id/walletStr"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/cancelBtn"
android:text="cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/buyBtn"
android:text="buy"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
On the simulator, this produces the desired effect, but on the actual device almost all of the space goes to the top listview.
Any ideas? Thanks in advance.
linear layout not have only 2 list, also have more component and you have to consider.
The weightSum should be divided all component of this linear layout.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:weightSum="7"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:id="#+id/categoryList" />
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:id="#+id/itemList" />
<TextView
android:id="#+id/walletStr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5">
<Button
android:id="#+id/cancelBtn"
android:text="cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/buyBtn"
android:text="buy"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
Trying to align button at Bottom using LinearLayout, but getting just below TextView.
To set button at bottom, I am using android:layout_gravity="bottom" but still not done
LinearLayout xml
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_gravity="bottom"
android:layout_height="wrap_content">
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Bottom" />
</LinearLayout>
</LinearLayout>
Change second linear layout to
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
This will put the button at the bottom and this layout will take the rest of the space
Yoy have to use like this....
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center">
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Bottom" />
</RelativeLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_gravity="bottom"
android:layout_height="wrap_content">
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Bottom" />
</LinearLayout>
</LinearLayout>
I could not use the suggested answer as I had multiples of 3 vertical ones (each with specific weights) inside a horizontal one. So, ended up using margin top for specific button/widget instead. Working fine so far.
Did not want to change to RelativeLayout as that meant many changes in this scenario.
Here is my Code
<LinearLayout android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:layout_height="wrap_content">
<RadioButton android:id="#+id/preference_question_optionTwo" android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
</LinearLayout>
Now here when i apply android:layout_weight="1" on LinearLayout the image does not appear.Without this property image is displayed.
What i want is to divide the layout into two parts. Both parts containing the same code above i.e a radio button and besides that an image and a text
Update This is how i want it
This is what i am getting as output
You didn't share the rest of your code or your intentions on how you want to divide the screen into two: vertically or horizontally.
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout android:layout_width="0dp"
android:orientation="horizontal"
android:layout_height="match_parent"
android:layout_weight="1" >
<RadioButton android:id="#+id/preference_question_optionOne" android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
</LinearLayout>
<LinearLayout android:layout_width="0dp"
android:orientation="horizontal"
android:layout_height="match_parent"
android:layout_weight="1" >
<RadioButton android:id="#+id/preference_question_optionTwo" android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
It seems that you got confused by the weight concept. It will be more clear this way, I guess. You should divide the parent's width or height according to those weights. Also don't forget to use it with 0dp.
If you want to divide the parent vertically, use this combination:
android:layout_height="0dp"
android:layout_width="match_parent" <!--or wrap_content-->
android:layout_weight="x"
and for horizontally
android:layout_height="match_parent" <!--or wrap_content-->
android:layout_width="0dp"
android:layout_weight="x"
The layout weight property is for elements within a linear layout. You should give each half of the screen the same weight and put them both within a linear layout.
Here's what you need:
<LinearLayout android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_height="match_parent"
android:layout_width="match_parent">
<!-- first half -->
<LinearLayout android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:layout_height="wrap_content">
<RadioButton android:id="#+id/preference_question_optionTwo" android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
</LinearLayout>
<!-- first half, same weight as first half -->
<LinearLayout android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:layout_height="wrap_content">
<RadioButton android:id="#id/preference_question_optionTwo" android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
If You need to divide Your layout in two parts with the same width, you need to set childs width to fill_parent and set the same wieght (> 1) to children.
For example:
<LinearLayout android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_height="wrap_content">
<RadioButton android:id="#+id/preference_question_optionTwo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
</LinearLayout>
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>