1

I am having an issue getting a component on my RelativeLayout to appear as I would like.

I am looking to create a static layout, that stays in place, in front of a ScrollView. The effect I am looking for is similar to the 'One Today' App (the controls at the bottom stay in place, and the items - in this case, the boy drinking water - scroll 'behind' that bar).

enter image description here

In the layout I am using now, the top element (the LinearLayout with id:top_control_ll) just doesn't show up at all. All the contents contained within ScrollView show up, but not the bar (that I am hoping would be locked to the top of the main RelativeLayout, per the attributes I set):

<?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="@color/second_grey"
    android:overScrollMode="always" >

    <LinearLayout
        android:id="@+id/top_control_ll"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:orientation="horizontal"
        android:baselineAligned="false" >

        <Button
            android:id="@+id/app_download2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/play_icon"
            android:text="@string/download"
            android:textColor="@color/download_button_color"
            android:textStyle="bold" />
    </LinearLayout>

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/second_grey" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@color/second_grey"
            android:orientation="vertical" >

            <!-- Title -->
            <RelativeLayout
                android:id="@+id/title_layout"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/app_title"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_horizontal"
                    android:text="@string/app_title" />

                <ImageView
                    android:id="@+id/app_icon"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_below="@+id/app_title" />

                <TextView
                    android:id="@+id/app_dotdcomment"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_below="@+id/app_title"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="8dp"
                    android:layout_toRightOf="@+id/app_icon" />
            </RelativeLayout>

            <LinearLayout
                android:id="@+id/icon_button_ll"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/big_card"
                android:orientation="horizontal"
                android:padding="16dp" >

                <ImageView
                    android:id="@+id/app_iconx"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginRight="20dp"
                    android:layout_weight="1" />

                <RelativeLayout
                    android:id="@+id/button_rl"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="horizontal" >

                    <Button
                        android:id="@+id/app_download"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@drawable/blue_button"
                        android:drawableLeft="@drawable/play_icon"
                        android:text="@string/download" />

                    <ImageButton
                        android:id="@+id/app_like"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/app_download"
                        android:background="@null" />

                    <ImageButton
                        android:id="@+id/app_hate"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/app_download"
                        android:layout_toRightOf="@+id/app_like"
                        android:background="@null" />
                </RelativeLayout>
            </LinearLayout>

            <!-- Screens -->

            <HorizontalScrollView
                android:id="@+id/app_screens_layout"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/title_layout"
                android:background="@drawable/big_card" >

                <LinearLayout
                    android:id="@+id/screens_layout"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <ImageView
                        android:id="@+id/screen1"
                        android:layout_width="150dp"
                        android:layout_height="250dp"
                        android:layout_marginLeft="8dp"
                        android:layout_marginRight="8dp" />

                    <ImageView
                        android:id="@+id/screen2"
                        android:layout_width="150dp"
                        android:layout_height="250dp"
                        android:layout_marginLeft="8dp"
                        android:layout_marginRight="8dp" />

                    <ImageView
                        android:id="@+id/screen3"
                        android:layout_width="150dp"
                        android:layout_height="250dp"
                        android:layout_marginLeft="8dp"
                        android:layout_marginRight="8dp" />

                    <ImageView
                        android:id="@+id/screen4"
                        android:layout_width="150dp"
                        android:layout_height="250dp"
                        android:layout_marginLeft="8dp"
                        android:layout_marginRight="8dp" />

                    <ImageView
                        android:id="@+id/screen5"
                        android:layout_width="150dp"
                        android:layout_height="250dp"
                        android:layout_marginLeft="8dp"
                        android:layout_marginRight="8dp" />
                </LinearLayout>
            </HorizontalScrollView>

        </LinearLayout>
    </ScrollView>

</RelativeLayout>
Booger
  • 18,579
  • 7
  • 55
  • 72
  • Did you check in your graphic layout if items are overlapping? – Noman Arain Nov 11 '13 at 17:36
  • Not sure I understand your question. The LinearLayout I am asking about, doesn't appear at all. – Booger Nov 11 '13 at 17:41
  • @Booger The `LinearLayout` in question _is_ being drawn - behind the `ScrollView`. Children of `RelativeLayout` are drawn in the order they appear in your layout. Since ScrollView is set up to fill the screen && its defined after the LinearLayout, `top_control_ll` isn't visible. Solution: Cut the LinearLayout definition and paste it after ``. – Vikram Nov 19 '13 at 17:31

0 Answers0