samedi 16 mai 2015

ScrollView with RelativeLayout messes up my view

I am having a problem with my xml. I have the below RelativeLayout.

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    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.maps.spotme.BranchDetails" >

    <ImageView
        android:id="@+id/pointPicture"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="5dp"
        android:contentDescription="@string/contentDescriptor"
        android:scaleType="center"
        android:src="@drawable/piraios" />

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/pointPicture"
        android:layout_marginLeft="25dp"
        android:layout_toRightOf="@+id/pointPicture"
        android:ellipsize="marquee"
        android:gravity="left"
        android:textSize="17sp"
        android:textStyle="bold" />

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:layout_alignLeft="@+id/pointPicture"
        android:layout_below="@+id/pointPicture"
        android:layout_marginTop="20dp"
        android:background="#000000"
        android:contentDescription="@string/contentDescriptor"
        android:src="@android:drawable/divider_horizontal_bright" />

    <TextView
        android:id="@+id/province"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/street"
        android:layout_below="@+id/street"
        android:ellipsize="marquee"
        android:gravity="left"
        android:scrollHorizontally="true"
        android:singleLine="false"
        android:textSize="14sp" />

    <ImageView
        android:id="@+id/addressIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/pointPicture"
        android:layout_below="@+id/pointPicture"
        android:layout_marginTop="40dp"
        android:contentDescription="@string/contentDescriptor"
        android:src="@drawable/address" />

    <TextView
        android:id="@+id/street"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/addressIcon"
        android:layout_toRightOf="@+id/pointPicture"
        android:ellipsize="marquee"
        android:gravity="left"
        android:scrollHorizontally="true"
        android:singleLine="false"
        android:textSize="14sp" />

    <TextView
        android:id="@+id/distanceMeters"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/distanceIcon"
        android:layout_marginBottom="7dp"
        android:layout_marginLeft="15dp"
        android:layout_toRightOf="@+id/distanceIcon"
        android:textSize="14sp" />

    <Button
        android:id="@+id/phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/addressIcon"
        android:layout_below="@+id/province"
        android:layout_marginTop="20dp"
        android:background="?android:selectableItemBackground"
        android:drawableLeft="@drawable/phone"
        android:drawablePadding="15dp"
        android:paddingTop="0dp"
        android:textSize="14sp" />

    <ImageView
        android:id="@+id/distanceIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/phone"
        android:layout_below="@+id/phone"
        android:layout_marginTop="20dp"
        android:contentDescription="@string/contentDescriptor"
        android:src="@drawable/distance" />

    <ImageView
        android:id="@+id/openClose"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/phone"
        android:layout_marginRight="45dp"
        android:layout_marginTop="7dp"
        android:contentDescription="@string/contentDescriptor"
        android:src="@drawable/open" />

    <Button
        android:id="@+id/toMap"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/distanceMeters"
        android:layout_alignBottom="@+id/distanceMeters"
        android:layout_alignLeft="@+id/openClose"
        android:background="?android:selectableItemBackground"
        android:drawableLeft="@drawable/map"
        android:drawablePadding="15dp"
        android:text="@string/toMap"
        android:textSize="14sp" />

    <Button
        android:id="@+id/showTimetable"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/distanceIcon"
        android:layout_below="@+id/distanceIcon"
        android:layout_marginTop="20dp"
        android:background="?android:selectableItemBackground"
        android:drawableLeft="@drawable/diary"
        android:drawablePadding="15dp"
        android:text="@string/timetable"
        android:textSize="14sp" />

    <Button
        android:id="@+id/reportBroken"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/showTimetable"
        android:layout_below="@+id/showTimetable"
        android:layout_marginTop="14dp"
        android:background="?android:selectableItemBackground"
        android:drawableLeft="@drawable/error"
        android:drawablePadding="15dp"
        android:text="@string/broken"
        android:textSize="14sp" />

</RelativeLayout>

This is the view in this picture (without scroll view)

http://ift.tt/1HkeM9S

When I try to add a scroll view the closed icon is messed up

http://ift.tt/1AamKCu

I've tried many solutions found here in StackOverflow, like the following (the arrows mean children)

  • Relative -> Scroll -> Relative
  • Scroll -> Linear -> Relative

but nothing seems to fix the problem. Any thoughts? Thank you in advance

Aucun commentaire:

Enregistrer un commentaire