I am having a problem with my xml. I have the below RelativeLayout.
<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: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)
https://imageshack.us/i/p8PI7EpSp
When I try to add a scroll view the closed icon is messed up
https://imageshack.us/i/f0Fz1DPEp
I've tried many solutions found here in StackOverflow, like the following (the arrows mean children)
but nothing seems to fix the problem. Any thoughts? Thank you in advance
Update
ScrollView xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:fillViewport="true"
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" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<!-- The yellow imageView in the beginning -->
<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" />
<!-- The name next to the yellow imageView -->
<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" />
<!-- The horizontal line -->
<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" />
<!-- The second textView next to the road icon -->
<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" />
<!-- The road icon -->
<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" />
<!-- The first textView next to the road icon -->
<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" />
<!-- The m. icon text -->
<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" />
<!-- The phone icon with the phone text -->
<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" />
<!-- The m. icon -->
<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" />
<!-- The closed icon (where the problem is) -->
<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" />
<!-- The map icon -->
<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" />
<!-- The calendar icon -->
<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" />
<!-- The exclamation mark(!) icon -->
<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>
</ScrollView>
I may be wrong but the layout dimensions seem wrong to me.
You are currently using wrap_content
to set the width/height on your ScrollView
which means your 45dp
margin on openClose
is causing the content to overflow, I believe.
Try this:
<ScrollView 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:background="#FFFFFF"
android:fillViewport="true"
tools:context="com.maps.spotme.BranchDetails" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<!-- Your Content Here -->
</RelativeLayout>
</ScrollView>