<?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:background="#1E1E1E"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="#+id/button7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 3"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:singleLine="false"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:singleLine="false"
android:text="Botton 2"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 3"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 4"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 5"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 6"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:background="#fff"
android:weightSum="6" >
<Button
android:id="#+id/b1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#id/b1"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/home1"
android:text="Home"
android:textSize="8dp" />
<Button
android:id="#+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/b2"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/abt"
android:text="About"
android:textSize="8dp" />
<Button
android:id="#+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/b3"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/ser"
android:text="Services"
android:textSize="8dp" />
<Button
android:id="#+id/b4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/b4"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/cnt1"
android:text="Portfolio"
android:textSize="8dp" />
<Button
android:id="#+id/b5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/b5"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/spt"
android:text="Support"
android:textSize="8dp" />
<Button
android:id="#+id/b6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/b6"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/inbox"
android:text="Marketing"
android:textSize="8dp" />
</LinearLayout>
</RelativeLayout>
I Need to have scroll view in the relative layout with fixed footer. the table layout alone should have scroll view and footer should be fixed
Add a scroll view as a parent of your TableLayout and align it above bottom layout.
<?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:background="#1E1E1E" >
<LinearLayout
android:id="#+id/bottombar"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:background="#fff"
android:weightSum="6" >
<Button
android:id="#+id/b1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#id/b1"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/home1"
android:text="Home"
android:textSize="8dp" />
<Button
android:id="#+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/b2"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/abt"
android:text="About"
android:textSize="8dp" />
<Button
android:id="#+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/b3"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/ser"
android:text="Services"
android:textSize="8dp" />
<Button
android:id="#+id/b4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/b4"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/cnt1"
android:text="Portfolio"
android:textSize="8dp" />
<Button
android:id="#+id/b5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/b5"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/spt"
android:text="Support"
android:textSize="8dp" />
<Button
android:id="#+id/b6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/b6"
android:layout_weight="1"
android:background="#fff"
android:drawableTop="#drawable/inbox"
android:text="Marketing"
android:textSize="8dp" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/bottombar" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="#+id/button7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 3"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:singleLine="false"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:singleLine="false"
android:text="Botton 2"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 3"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 4"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:weightSum="1" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ld"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 5"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" >
<Button
android:id="#+id/button6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:gravity="center|bottom"
android:paddingBottom="10dp"
android:text="Button 6"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</TableRow>
</TableLayout>
</ScrollView>
</RelativeLayout>
Use this as your top level and add to it what you need:
<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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:weightSum="1"
tools:context=".MainActivityFragment">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".1"
android:orientation="horizontal"
android:id="#+id/footer">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
Inside your given xml code add a scroll view and replace your TableLayout inside it. Like this,Let it be first layout.
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1E1E1E">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
//contents inside table layout
</TableLayout>
</ScrollView>
</RelativeLayout>
Now create another footer Layout,like this,let it be second layout.
<RelativeLayout>
//things to be appeared on footer are added here
</RelativeLayout>
Inside your java code,get both the layouts using their ids, set the second layout as footter to the first layout.
firstlayout.addFooterView(secondlayout);
Now you can get a fixed footer and scrolling will be only within the first layouts table layout.
Related
I want to create an activity that contains 5 "FrameLayout" like the picture below.
3 equal FrameLayout in the first row and 2 FrameLayout in the second row.
I did it using Linear layouts but I got a warning that nested weights are bad. So is there an other way to make it.
Fragments should be streched on the screen without using values like (100dp).
you cal also use the two table layout..
like
<TableLayout android:weight='1'>
<TableRow>
<Linear>
<FrameLayout /> <FrameLayout /> <FrameLayout />
</Linear>
</TableRow>
</TableLayout>
<TableLayout android:weight='1'>
<TableRow>
<Linear>
<FrameLayout /> <FrameLayout/>
</Linear>
</TableRow>
</TableLayout>
its rough layout . i hope you got the idea.
Try this
<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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#00bbff" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="1" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#bb00ff" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="2" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#00ff00" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="3" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#bbff00">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="4" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#ffbb00" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="5" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
Try this::Hope its useful for you.
<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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#00bbff"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="1" />
</FrameLayout>
<View android:layout_width="10dp"
android:layout_height="10dp"
/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#bb00ff"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="2"
/>
</FrameLayout>
<View android:layout_width="10dp"
android:layout_height="10dp"
/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#00ff00"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="3" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp">
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#bbff00" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="4" />
</FrameLayout>
<View android:layout_width="10dp"
android:layout_height="10dp"
/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#ffbb00" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="5" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
see image below ![image][1]
See This code
<?xml version="1.0" encoding="utf-8"?>
<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">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="2dp"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="2dp"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="1"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_marginTop="2dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="150dp"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"/>
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:gravity="center"
android:layout_marginLeft="1dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4" />
</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 am creating a simon says app and it's going well except the layout.
As you can see on the image below I have no idea how to get my buttons like the example on the right.
I have tried many things but none of them worked, I'd just like that the buttons auto fill up the space they get.
My XML file looks like this (left example):
<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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.xyz.MainActivity" >
<RelativeLayout
android:id="#+id/row_one"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/gameScore" />
<TextView
android:id="#+id/turn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Who's turn is it?" />
</RelativeLayout>
<LinearLayout
android:id="#+id/row_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/row_one" >
<Button
android:id="#+id/green"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:background="#drawable/green_button"
android:onClick="simon_onClick"
android:padding="3dp"
android:text="Green"
android:textColor="#ffffff" />
<Button
android:id="#+id/red"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#drawable/red_button"
android:onClick="simon_onClick"
android:padding="3dp"
android:text="Red"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:id="#+id/row_three"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/row_two"
android:layout_marginTop="2dp" >
<Button
android:id="#+id/yellow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:background="#drawable/yellow_button"
android:onClick="simon_onClick"
android:padding="3dp"
android:text="Yellow"
android:textColor="#ffffff" />
<Button
android:id="#+id/blue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#drawable/blue_button"
android:onClick="simon_onClick"
android:padding="3dp"
android:text="Blue"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center|bottom"
android:orientation="vertical" >
<Button
android:id="#+id/status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center"
android:onClick="startGame"
android:text="#string/gameStatus_start" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Thank you guys in advance!
You can use this one also:
<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:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:orientation="vertical"
android:paddingTop="10dp" >
<LinearLayout
android:id="#+id/row_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="30dp" >
<TextView
android:id="#+id/score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="gameScore" />
<TextView
android:id="#+id/turn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Who's turn is it?" />
</LinearLayout>
<LinearLayout
android:id="#+id/row_two"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2" >
<Button
android:id="#+id/green"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:background="#00ff00"
android:onClick="simon_onClick"
android:padding="3dp"
android:text="Green"
android:textColor="#ffffff" />
<Button
android:id="#+id/red"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#ff0000"
android:onClick="simon_onClick"
android:padding="3dp"
android:text="Red"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:id="#+id/row_three"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:layout_marginTop="2dp" >
<Button
android:id="#+id/yellow"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:background="#ddaa00"
android:onClick="simon_onClick"
android:padding="3dp"
android:text="Yellow"
android:textColor="#ffffff" />
<Button
android:id="#+id/blue"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#0000ff"
android:onClick="simon_onClick"
android:padding="3dp"
android:text="Blue"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="40dp"
android:orientation="vertical"
android:layout_gravity="bottom"
>
<Button
android:id="#+id/status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center"
android:onClick="startGame"
android:text="gameStatus_start" />
</LinearLayout>
Can you use LinearLayout(Vertical) as root layout?
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>