I'm trying to make a "gamepad" with WASD and arrows in each side like this:
but instead of the arrow pad being below WASD i want them to be in the same "line" with the WASD in the left and arrows in the right
can someone help me with this (i'm not posting my code since it's garbage and not even close to the solution, it's just to illustrate what i'm trying to do)?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/menubg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="W" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="A" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="S" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="D" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="↑" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="←" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="↓" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="→" />
</LinearLayout>
</LinearLayout>
try this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<LinearLayout
android:id="#+id/mainArrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/keypad"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="W" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:orientation="horizontal"
android:weightSum="9" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:focusable="false"
android:text="A" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:focusable="false"
android:text="S" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:focusable="false"
android:text="D" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/arrow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:text="↑" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:orientation="horizontal"
android:weightSum="9" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:focusable="false"
android:text="←" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:focusable="false"
android:text="↓" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:focusable="false"
android:text="→" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Related
I have a fragment layout that looks like this:
The top 3 rows are spaced nicely, but the age and sex rows are too short vertically. If I were to hard code a vertical size for the entire layout, is there a way to ensure every item is evenly spaced vertically? Currently, due to the different widget types being used, the bottom too dont look very nice
Here is the code for my layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Research Assistant:" />
<EditText
android:id="#+id/input_ra"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="textCapWords"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Subject Number:" />
<EditText
android:id="#+id/input_subnum"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="text"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Condition:" />
<EditText
android:id="#+id/input_condition"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="number"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Age:" />
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/input_age_spinner"
android:layout_weight="0.6" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Sex:" />
<RadioGroup
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:id="#+id/input_button_male"
android:paddingRight="10dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:id="#+id/input_button_female"
android:paddingRight="10dp"/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="50dp">
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:orientation="horizontal" >
<Button
android:id="#+id/input_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Save" />
<Button
android:id="#+id/input_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Reset" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Try this. Each row view is equally apart from each other.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="20dp"
android:weightSum="12"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="2" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Research Assistant:" />
<EditText
android:id="#+id/input_ra"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:textAppearance="#android:style/TextAppearance.Medium"
android:ems="10"
android:inputType="textCapWords"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="2"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Subject Number:" />
<EditText
android:id="#+id/input_subnum"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="text"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:gravity="center"
android:layout_weight="2"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Condition:" />
<EditText
android:id="#+id/input_condition"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="number"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="2"
android:gravity="center"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Age:" />
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/input_age_spinner"
android:layout_weight="0.6" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="2"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Sex:" />
<RadioGroup
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:id="#+id/input_button_male"
android:paddingRight="10dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:id="#+id/input_button_female"
android:paddingRight="10dp"/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:gravity="center"
android:layout_weight="2"
android:weightSum="1">
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="0.75"
android:orientation="horizontal" >
<Button
android:id="#+id/input_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Save" />
<Button
android:id="#+id/input_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Reset" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Hope this works for you.
Perhaps you could consider using weightSum and weight attribute to evenly distribute it.
Below is the edited code based on that. Noted your height would be now 0dp, and I give more weight to the last buttons.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="10"
android:padding="20dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Research Assistant:" />
<EditText
android:id="#+id/input_ra"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="textCapWords"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Subject Number:" />
<EditText
android:id="#+id/input_subnum"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="text"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Condition:" />
<EditText
android:id="#+id/input_condition"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="number"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Age:" />
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/input_age_spinner"
android:layout_weight="0.6" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Sex:" />
<RadioGroup
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:id="#+id/input_button_male"
android:paddingRight="10dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:id="#+id/input_button_female"
android:paddingRight="10dp"/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:paddingTop="50dp"
android:orientation="horizontal">
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:orientation="horizontal" >
<Button
android:id="#+id/input_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Save" />
<Button
android:id="#+id/input_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Reset" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
I have designed this User Interface since it wont show the whole activity I want to put a scrollview to the layout.When I put in to a scroll view some buttons postion changes.how can I change it?
XML Code:
<LinearLayout 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"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="#3697dc"
android:weightSum="1">
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#3697dc"
>
<Button
android:id="#+id/TextView1"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/polonnaruwa"
android:layout_margin="5dp"
/>
<Button
android:id="#+id/TextView2"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/anuradhapura"
android:layout_margin="5dp"
/>
<Button
android:id="#+id/TextView3"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/dambulla"
android:layout_margin="5dp"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#3697dc"
android:layout_gravity="bottom">
<Button
android:id="#+id/textView2"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.5"
android:background="#drawable/kandy"
android:layout_margin="5dp" />
<Button
android:id="#+id/textView"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.24"
android:background="#drawable/trincomalee"
android:layout_margin="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#3697dc"
android:layout_gravity="center_horizontal">
<Button
android:id="#+id/textView3"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.24"
android:background="#drawable/galle"
android:layout_margin="5dp" />
<Button
android:id="#+id/textView4"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.5"
android:background="#drawable/colombo"
android:layout_margin="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#3697dc"
android:layout_gravity="center_horizontal">
<Button
android:id="#+id/textView5"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/hikkaduwa"
android:layout_margin="5dp" />
<Button
android:id="#+id/textView6"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/yala"
android:layout_margin="5dp" />
<Button
android:id="#+id/textView7"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/bentota"
android:layout_margin="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#3697dc"
android:layout_gravity="center_horizontal" >
<Button
android:id="#+id/textView9"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.5"
android:background="#drawable/nuwaraeliya"
android:layout_margin="5dp" />
<Button
android:id="#+id/textView8"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.24"
android:background="#drawable/ratnapura"
android:layout_margin="5dp" />
</LinearLayout>
<ScrollView
android:layout_weight="0.10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
>
</ScrollView>
</LinearLayout>
I am sorry If I don't get you, but I think this is what you need...
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.10"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#3697dc"
android:orientation="vertical"
android:weightSum="1"
tools:context=".MainActivity" >
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#3697dc"
android:orientation="horizontal" >
<Button
android:id="#+id/TextView1"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="polonnaruwa" />
<Button
android:id="#+id/TextView2"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="anuradhapura" />
<Button
android:id="#+id/TextView3"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="dambulla" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#3697dc"
android:orientation="horizontal" >
<Button
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="0.5"
android:text="kandy" />
<Button
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="0.24"
android:text="trincomalee" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#3697dc"
android:orientation="horizontal" >
<Button
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="0.24"
android:text="galle" />
<Button
android:id="#+id/textView4"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="0.5"
android:text="colombo" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#3697dc"
android:orientation="horizontal" >
<Button
android:id="#+id/textView5"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="hikkaduwa" />
<Button
android:id="#+id/textView6"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="yala" />
<Button
android:id="#+id/textView7"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="bentota" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#3697dc"
android:orientation="horizontal" >
<Button
android:id="#+id/textView9"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="0.5"
android:text="nuwaraeliya" />
<Button
android:id="#+id/textView8"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:layout_weight="0.24"
android:text="ratnapura" />
</LinearLayout>
</LinearLayout></ScrollView>
Hope it helps :)
Just put the view (layout) you want to scroll inside <scrollView> </scrollView> tag.
<LinearLayout 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"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="#3697dc"
android:weightSum="1">
<ScrollView
android:layout_weight="0.10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
>
<Relative Layout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#3697dc"
>
<Button
android:id="#+id/TextView1"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/polonnaruwa"
android:layout_margin="5dp"
/>
<Button
android:id="#+id/TextView2"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/anuradhapura"
android:layout_margin="5dp"
/>
<Button
android:id="#+id/TextView3"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/dambulla"
android:layout_margin="5dp"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#3697dc"
android:layout_gravity="bottom">
<Button
android:id="#+id/textView2"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.5"
android:background="#drawable/kandy"
android:layout_margin="5dp" />
<Button
android:id="#+id/textView"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.24"
android:background="#drawable/trincomalee"
android:layout_margin="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#3697dc"
android:layout_gravity="center_horizontal">
<Button
android:id="#+id/textView3"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.24"
android:background="#drawable/galle"
android:layout_margin="5dp" />
<Button
android:id="#+id/textView4"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.5"
android:background="#drawable/colombo"
android:layout_margin="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#3697dc"
android:layout_gravity="center_horizontal">
<Button
android:id="#+id/textView5"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/hikkaduwa"
android:layout_margin="5dp" />
<Button
android:id="#+id/textView6"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/yala"
android:layout_margin="5dp" />
<Button
android:id="#+id/textView7"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/bentota"
android:layout_margin="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#3697dc"
android:layout_gravity="center_horizontal" >
<Button
android:id="#+id/textView9"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.5"
android:background="#drawable/nuwaraeliya"
android:layout_margin="5dp" />
<Button
android:id="#+id/textView8"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="0.24"
android:background="#drawable/ratnapura"
android:layout_margin="5dp" />
</LinearLayout>
</Relative Layout>
</ScrollView>
</LinearLayout>
You must set fixed size to your ScrollView. In XML or calculate the height of all childrens in it, then sum and set to ScrollView.
Put scroll View tag in the top of your views (listviews , linear ...etc)
make it width / height match parent
here is Example
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:id="#+id/GlobalLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView android:id="#+id/ListView1"
android:choiceMode="multipleChoice"
android:layout_height="100dip"
android:layout_width="fill_parent" />
<ListView android:id="#+id/ListView2"
android:choiceMode="multipleChoice"
android:layout_height="100dip"
android:layout_width="fill_parent" />
<ListView android:id="#+id/ListView3"
android:choiceMode="multipleChoice"
android:layout_height="100dip"
android:layout_width="fill_parent" />
</LinearLayout>
</ScrollView>
I am having a screen which has many layouts having title,list view ,comment and buttons but buttons are not getting displayed at all,after list view display I am getting a huge amount of empty space after which comment is getting displayed and buttons are not seen ,this is my code.
<?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="vertical"
android:background="#android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_margin="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="12345617890" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:fontFamily="#android:color/black"
android:text="Ramakrisha Tripati" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="9876543210" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1"
android:layout_margin="10dp"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="13/1/2015" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Rohit Sharma" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="55dp"
android:orientation="horizontal"
android:background="#android:color/holo_orange_light">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="item#\nstyle#"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="M Wt\nD Wt\nCS Wt"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Making\nD Rate\nCS Rate"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Margin\nDis %\nDiscount"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GT\nFSP"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="#00000000"
android:dividerHeight="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25dp"
android:text="Comment" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:ems="10"
android:hint="Comment goes here"
android:inputType="textMultiLine" />
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="accept"
android:src="#drawable/accept"
/>
</LinearLayout>
I have modified your layout code and now the button has appeared.
<?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:background="#android:color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="12345617890" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:fontFamily="#android:color/black"
android:text="Ramakrisha Tripati" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="9876543210" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="13/1/2015" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Rohit Sharma" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="#android:color/holo_orange_light"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="item#\nstyle#" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="M Wt\nD Wt\nCS Wt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Making\nD Rate\nCS Rate" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Margin\nDis %\nDiscount" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="GT\nFSP" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="#00000000"
android:dividerHeight="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Comment"
android:textSize="25dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:ems="10"
android:hint="Comment goes here"
android:inputType="textMultiLine" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:onClick="accept"
android:src="#drawable/accept" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Just put your main LinearLayout inside scrollview and you will see thr buttons.
And if not so maybe your image is so small or transparent.
check with another image maybe.
I want to make some thing like this
Trying following code but in view layouts are not properly aligned can someone help me out with this.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical" >
<TextView
android:id="#+id/txtServices"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Services "
android:textSize="22dp" />
<LinearLayout
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" >
<CheckBox
android:id="#+id/chkService1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Dine In" />
<CheckBox
android:id="#+id/chkService2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Take Away" />
<CheckBox
android:id="#+id/chkService3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Home Delivery" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/chkService4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="BYO" />
<CheckBox
android:id="#+id/chkService5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Bar" />
<CheckBox
android:id="#+id/chkService6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Gluten Free" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/chkService7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Vegan" />
<CheckBox
android:id="#+id/chkService8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Vegiterian" />
<CheckBox
android:id="#+id/chkService9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Organic" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Try to align all check boxes properly to get view as shown. I have tried with managing vertical layouts but not helping.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical" >
<TextView
android:id="#+id/txtServices"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Services "
android:textSize="22dp" />
<LinearLayout
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" >
<CheckBox
android:id="#+id/chkService1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Dine In"
android:textSize="10dp" />
<CheckBox
android:id="#+id/chkService2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Take Away"
android:textSize="10dp" />
<CheckBox
android:id="#+id/chkService3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Home Delivery"
android:textSize="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/chkService4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="10dp"
android:text="BYO" />
<CheckBox
android:id="#+id/chkService5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="10dp"
android:text="Bar" />
<CheckBox
android:id="#+id/chkService6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="10dp"
android:text="Gluten Free" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/chkService7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="10dp"
android:text="Vegan" />
<CheckBox
android:id="#+id/chkService8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="10dp"
android:text="Vegiterian" />
<CheckBox
android:id="#+id/chkService9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="10dp"
android:text="Organic" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
You should use 0dp as width when you use Weight property:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical" >
<TextView
android:id="#+id/txtServices"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Services "
android:textSize="22dp" />
<LinearLayout
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" >
<CheckBox
android:id="#+id/chkService1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Dine In" />
<CheckBox
android:id="#+id/chkService2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Take Away" />
<CheckBox
android:id="#+id/chkService3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Home Delivery" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/chkService4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="BYO" />
<CheckBox
android:id="#+id/chkService5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Bar" />
<CheckBox
android:id="#+id/chkService6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Gluten Free" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/chkService7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Vegan" />
<CheckBox
android:id="#+id/chkService8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Vegiterian" />
<CheckBox
android:id="#+id/chkService9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Organic" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Hope this helps.
I have two questions, the first is that I would like the buttons to be on the bottom corner of the screen stacked like they are (they currently are in the middle) and I would like them to be the same size, currently the top 2 buttons are bigger then the bottom two buttons. Also maybe lowering the texview boxes down a little if that is easy enough.
<?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" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center" >
<EditText
android:id="#+id/playerLifeOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:inputType="number"
android:minWidth="120dp"
android:text="20"
android:textSize="40dp" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/badd1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="+1" />
<Button
android:id="#+id/badd5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="+5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/bsub1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-1" />
<Button
android:id="#+id/bsub5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-5" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center" >
<EditText
android:id="#+id/playerLifeTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:inputType="number"
android:minWidth="120dp"
android:text="20"
android:textSize="40dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="right"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/b2add1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="+1" />
<Button
android:id="#+id/b2add5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="+5" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/b2sub1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-1" />
<Button
android:id="#+id/b2sub5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-5" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Check now.
<?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" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center" >
<EditText
android:id="#+id/playerLifeOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="50dp"
android:inputType="number"
android:minWidth="120dp"
android:text="20"
android:textSize="40dp" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
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:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/badd1"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="+1" />
<Button
android:id="#+id/badd5"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="+5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/bsub1"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="-1" />
<Button
android:id="#+id/bsub5"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="-5" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center" >
<EditText
android:id="#+id/playerLifeTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="50dp"
android:inputType="number"
android:minWidth="120dp"
android:text="20"
android:textSize="40dp" />
</LinearLayout>
<LinearLayout
android:layout_width="156dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/b2add1"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="+1" />
<Button
android:id="#+id/b2add5"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="+5" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/b2sub1"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="-1" />
<Button
android:id="#+id/b2sub5"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="-5" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
All buttons should look like this one.-
<Button
android:id="#+id/badd5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="+5" />
Check layout_width and layout_weight properties.
As for the EditTexts, you have several options, an easy one would be applying some top margin.-
<EditText
android:id="#+id/playerLifeOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:gravity="center"
android:inputType="number"
android:minWidth="120dp"
android:text="20"
android:textSize="40dp" >
just a tip: using a RelativeLayout would give you more flexibility and a more simple possibility to achieve what you need.
Note: in my sample project the Holo.Light theme is applied, that's why it looks a bit different.
<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" >
<!-- this is a SAMPLE layout. Adjust the values as you need them. -->
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="#000000"
android:orientation="vertical" >
</LinearLayout>
<EditText
android:id="#+id/editText1"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp"
android:ems="10" >
</EditText>
<EditText
android:id="#+id/editText2"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignBaseline="#+id/editText1"
android:layout_alignBottom="#+id/editText1"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:ems="10" >
<requestFocus />
</EditText>
<!-- do the same thing on the right side -->
<Button
android:id="#+id/btnMinOneLeft"
android:layout_width="50dp"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="-1" />
<Button
android:id="#+id/btnMinFiveLeft"
android:layout_width="50dp"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/btnMinOneLeft"
android:text="-5" />
<Button
android:id="#+id/btnPlusOneLeft"
android:layout_width="50dp"
android:layout_height="60dp"
android:layout_above="#+id/btnMinOneLeft"
android:layout_alignParentLeft="true"
android:text="+1" />
<Button
android:id="#+id/btnPlusFiveLeft"
android:layout_width="50dp"
android:layout_height="60dp"
android:layout_above="#+id/btnMinFiveLeft"
android:text="+5"
android:layout_toRightOf="#+id/btnPlusOneLeft"/>