I have an xml file that contains a ScrollView
and inside there is a LinearLayout
; this layout also contains 2 more layouts:
1st is where data will be added dynamically
2nd is a just something that needs to be displayed at the bottom of the view.
But gravity isn't working, I've tried both gravity
and layout_gravity
but none work, all layouts are set to fill the parent so why is this happening?
The copyright layout must be inside the ScrollView
but at the bottom of the screen even if ScrollView
is empty (1st layout).
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/istoricLayout"
android:visibility="visible" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/istoric"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" //here I'm trying to move this at the buttom
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="@dimen/thick_bar_height"
android:layout_marginBottom="@dimen/bar_vertical_space"
android:layout_marginTop="@dimen/bar_vertical_space"
android:background="@color/white" />
<Button
android:id="@+id/versiuneaCompleta"
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@color/color2"
android:text="Vizioneaza versiunea completa"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="15dp" />
<RelativeLayout
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@color/white" >
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:adjustViewBounds="true"
android:src="@drawable/support_right_icon" />
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:adjustViewBounds="true"
android:src="@drawable/support_left_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@color/white"
android:text="Support +40.XXX.XXX.XXX"
android:textAlignment="center"
android:textColor="@color/color2"
android:textSize="15dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Politica de condidentialitate ·"
android:textColor="@color/white"
android:textSize="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Despre noi ·"
android:textColor="@color/white"
android:textSize="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Contact"
android:textColor="@color/white"
android:textSize="10dp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="© 2013 Artcos Design. All Rights Reserved"
android:textColor="@color/copyRightColor"
android:textSize="10dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Move your textview, below the scrollview. You are using gravity in the wrong manner.
I assume you want your copyright at the bottom fixed.
Gravity is used to display contents of the view, in certain ways. or how to position the view itself, but it will not change the view hierarchy.
you will also need to change the scroll view, so it does not take the screen height, but instead will best fill the area leaving room for copyright notice: