Reputation: 21
hello I am working on a ios styled app that has a layout out the bottom well I can't seem to get this layout in question to be at the bottom
here's my 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"
android:weightSum="10"
tools:context=".MyActivity"
tools:ignore="UselessLeaf,ContentDescription" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
android:layout_weight="7" >
</android.support.v4.view.ViewPager>
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/pagerIndicator"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:padding="3dp" />
<LinearLayout
android:id="@+id/layout11"
android:layout_width="match_parent"
android:layout_height="30dip"
android:background="@drawable/dock"
android:layout_gravity="bottom"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center|bottom"
tools:ignore="NestedWeights" >
<ImageView
android:id="@+id/dial"
android:layout_width="wrap_content"
android:layout_height="10dp"
android:layout_gravity="center_horizontal|center"
android:src="@drawable/dialer"
tools:ignore="ContentDescription" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight="1" >
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="10dp"
android:layout_gravity="center_horizontal|center"
android:src="@drawable/back" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|center"
android:layout_weight="1" >
<ImageView
android:id="@+id/sms"
android:layout_width="wrap_content"
android:layout_height="10dp"
android:layout_gravity="center_horizontal|center"
android:src="@drawable/mms" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|center"
android:layout_weight="1" >
<ImageView
android:id="@+id/music"
android:layout_width="wrap_content"
android:layout_height="10dp"
android:src="@drawable/music"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
here's what it looks like right now: IMAGE
I want the buttons at the bottom of the page
what am I doing wrong?
please let me know
thanks a million times over
Chris
Upvotes: 0
Views: 135
Reputation: 14820
As Hesam's answer pointed out when you use the layout_weight
attribute in your 2nd layout you should make the layout_height=0dp
...if you're using Android Studio then it should be giving you a warning about it. However, I'd like to add to his answer that there's a lot of room for improvement in your layout file as a whole...and I mean A LOT!!! You've got what I call a spaguetti of useless nested layouts. To mention a few
LinearLayout
is absolutely useless...it's empty, not neededLinearLayout
can be easily converted to a RelativeLayout
, then push the bottom-most child view to the bottom using layout_alignParentBottom=true
and finally stack all other children on top of this bottom view using layout_above
LinearLayout
with one single child...IMHO this is uselessRelativeLayout
with one single child...IMHO this is useless as wellI could go on forever, but you really should address these nested layout issues because you are adding a lot of unnecessary overhead to your UI...this is pretty heavy man
This what I would recommend
RelativeLayout
as the root/top layoutListView
to display all those images/icons and set the layout_alignParentTop=true
with layout_height=wrap_content
LinearLayout
below it with a horizontal orientation to display the buttonsUpvotes: 1
Reputation: 23
You can use a RelativeLayout instead of LinearLayout as a root layout and then set android:layout_alignParentBottom="true" to the bottom layout
Upvotes: 0
Reputation: 806
You could use a RelativeLayout as parent and then use alignParentBottom=“true” however I am not completely sure what you are trying to achieve i.e. how it should look like.
Upvotes: 0
Reputation: 53600
When you are using android:layout_weight="1" then wither of android:layout_width or android:layout_height should be equal to 0dp. In your case second linear layout should be android:layout_height="0dp"
Upvotes: 0