Can´t add elements to HorizontalScrollView programatically - android

I'm inserting TextView elements dynamically, but only the last ones are inserted and the first ones are missing.
XML of HorizontalScrollView:
<HorizontalScrollView
android:id="#+id/mainScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="45dp"
android:layout_marginRight="45dp"
android:scrollbars="none">
<LinearLayout
android:id="#+id/scrollLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
Full XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/backround">
<RelativeLayout
android:id="#+id/article"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/linearLayout3"
android:layout_marginBottom="15dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="15dp"
android:background="#drawable/edittext">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/textView35"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
<HorizontalScrollView
android:id="#+id/mainScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="45dp"
android:layout_marginRight="45dp"
android:scrollbars="none">
<LinearLayout
android:id="#+id/scrollLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
<ImageView
android:id="#+id/imageView46"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_marginLeft="17dp"
android:layout_toEndOf="#+id/imageView45"
android:layout_toRightOf="#+id/imageView45"
app:srcCompat="#mipmap/likeicon" />
<ImageView
android:id="#+id/imageView45"
android:layout_width="125dp"
android:layout_height="45dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/pujar" />
<ImageView
android:id="#+id/imageView47"
android:layout_width="wrap_content"
android:layout_height="27dp"
android:layout_alignTop="#+id/imageView46"
android:layout_marginRight="13dp"
android:layout_toLeftOf="#+id/imageView45"
android:layout_toStartOf="#+id/imageView45"
app:srcCompat="#mipmap/deleteicon" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/relativeLayout5"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<TextView
android:id="#+id/textView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_toEndOf="#+id/imageView44"
android:layout_toRightOf="#+id/imageView44"
android:text="Article title"
android:textSize="15sp" />
<ImageView
android:id="#+id/imageView44"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
app:srcCompat="#mipmap/unknown" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/mainContentImage"
android:layout_width="match_parent"
android:layout_height="255dp"
android:layout_below="#+id/relativeLayout5"
android:background="#mipmap/surf">
</RelativeLayout>
<TextView
android:id="#+id/textView35"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/mainContentImage"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="Puja actual:"
android:textColor="#color/bidsy"
android:textSize="15sp" />
<TextView
android:id="#+id/textView36"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView35"
android:layout_alignBottom="#+id/textView35"
android:layout_marginLeft="3dp"
android:layout_toEndOf="#+id/textView35"
android:layout_toRightOf="#+id/textView35"
android:text="120"
android:textColor="#color/bidsy"
android:textSize="16sp" />
<TextView
android:id="#+id/textView37"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView35"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:text="1 Dia 4 horas"
android:textColor="#000000" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayoutBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#color/bidsy"
android:visibility="gone">
<ImageView
android:id="#+id/imageView15"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:clickable="true"
android:onClick="searchClick"
android:padding="12dp"
app:srcCompat="#mipmap/search" />
<ImageView
android:id="#+id/imageView144"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:clickable="true"
android:onClick="menuClick"
android:padding="10dp"
app:srcCompat="#mipmap/menu" />
<ImageView
android:id="#+id/imageViewBar"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#mipmap/title" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayoutSearchBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/relativeLayoutBar"
android:background="#color/bidsy">
<EditText
android:id="#+id/editText13"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="125dp"
android:background="#drawable/edittextsearch"
android:ems="10"
android:gravity="center"
android:hint="Busca en Bidsy!"
android:inputType="textPersonName"
android:textColor="#color/white"
android:textColorHint="#E95355" />
<ImageView
android:id="#+id/imageView155"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:padding="12dp"
app:srcCompat="#mipmap/search" />
<ImageView
android:id="#+id/imageView14"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:clickable="true"
android:onClick="menuClick"
android:padding="10dp"
app:srcCompat="#mipmap/menu" />
</RelativeLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/relativeLayoutSearchBar"
android:background="#color/white"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/tab1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar1"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView4354"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar2"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView4351"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar3"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView4356"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar4"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView43523"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar5"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView435233"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab6"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar6"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView435"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab7"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar7"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView43"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Code to load elements:
private void loadScrollElements() {
LinearLayout yourLayout = (LinearLayout) findViewById(R.id.scrollLayout);
for (int i = 1; i < 25; i++) {
TextView tv = new TextView(this);
tv.setText(i + "");
tv.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
tv.setTextSize(20);
yourLayout.addView(tv);
}
}
I see in mainScroll items from 11 to 24 + empty space.
Curiously that blank space seems to be the space that would take the missing elements at the beginning.
Why I don´t see 1..10 items?

The android:layout_gravity="center" of the LinearLayout causes the problem. When you change it to android:layout_gravity="center_vertical", all the TextView's will be visible again.
I'm not sure, but I guess that because the TextView's are added programmatically the LinearLayout miscalculates it's horizontal center.
Please correct me if I'm wrong.

Related

RelativeLayout takes more space than needed

I am working on a basic audio view for an android app (xamarin.android), i want to achieve the following result:
But instead i am getting this ugly result (ignore the other anomalies, focus on the layout):
The bottom relativeLayout (the one that holds the buttons) seems t get more space that actually needed, when i set the top RelativeLayout (the image holder) to match_parent the bottom RelativeLayout disappeared entirely even tho its high is set to wrap_content.
Here is my view's layout, what i am doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true"
android:id="#+id/top_parent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="#layout/Toolbar"
android:id="#+id/toolbar_content" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:layout_below="#id/toolbar_content"
android:id="#+id/gridLayout1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black"
android:id="#+id/cover_layout"
android:layout_marginBottom="0.0dp">
<ImageView
android:layout_width="500dp"
android:layout_height="400dp"
android:id="#+id/imageview_cover"
android:background="#color/gray"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true">
<TextView
android:id="#+id/textview_title"
android:gravity="left"
android:textColor="#color/white"
android:textStyle="bold"
android:text="Audio Book Title"
android:textSize="#dimen/text_very_huge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true" />
<TextView
android:id="#+id/textview_author"
android:gravity="left"
android:textColor="#color/colorAccent"
android:text="Author"
android:textSize="#dimen/text_small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/cover_layout"
android:id="#+id/relativeLayout2"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:background="#color/white"
android:layout_marginTop="0.0dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/relativeLayout3"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="#dimen/element_margin_tiny"
android:layout_marginBottom="#dimen/element_margin_tiny">
<TextView
android:text="Position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textview_position"
android:gravity="center"
android:layout_marginLeft="#dimen/element_margin_large"
android:textColor="#color/black"
android:layout_centerVertical="true" />
<SeekBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/textview_position"
android:id="#+id/player_seekbar"
android:layout_toLeftOf="#+id/textview_duration"
android:clickable="true"
style="#style/GreenSeekBar"
android:layout_centerVertical="true" />
<TextView
android:text="Duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textview_duration"
android:layout_alignParentRight="true"
android:layout_alignBottom="#+id/seekBar1"
android:layout_alignTop="#+id/seekBar1"
android:gravity="center"
android:layout_marginRight="#dimen/element_margin_large"
android:textColor="#color/black"
android:layout_centerVertical="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:id="#+id/relativeLayout5"
android:layout_below="#id/relativeLayout3"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ToggleButton
android:src="#drawable/toggle_sound"
android:id="#+id/btnSound"
android:layout_width="30dp"
android:layout_height="30dp"
android:textOff=" "
android:textOn=" "
android:layout_weight="2"
android:scaleType="center"
android:paddingLeft="#dimen/element_margin_tiny" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/btnPrevious"
android:background="#null"
android:src="#drawable/button_previous"
android:scaleType="center"
android:layout_toRightOf="#+id/btnSound"
android:layout_weight="2" />
<ToggleButton
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/btnPlayPause"
android:src="#drawable/togglebutton_playpause"
android:layout_centerVertical="true"
android:scaleType="center"
android:textOff=" "
android:textOn=" "
android:layout_toRightOf="#+id/btnPrevious"
android:layout_toLeftOf="#+id/btnNext"
android:layout_weight="2" />
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/btnNext"
android:background="#null"
android:src="#drawable/button_next"
android:scaleType="center"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/btnRepeat"
android:layout_weight="2" />
<ToggleButton
android:src="#drawable/toggle_playlist"
android:id="#+id/btnRepeat"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:textOff=" "
android:textOn=" "
android:scaleType="center"
android:layout_weight="2" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
you need to decrease your imageView size. And also you need to change your main layout to LinearLayout. Try below solution and it will work for you.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/gridLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/cover_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/relativeLayout2"
android:layout_alignParentTop="true"
android:layout_marginBottom="0.0dp" >
<ImageView
android:id="#+id/imageview_cover"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#color/gray" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical">
<TextView
android:id="#+id/textview_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:singleLine="true"
android:text="Audio Book Title"
android:textColor="#color/white"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textview_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:singleLine="true"
android:text="Author"
android:textColor="#color/colorAccent"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center"
android:layout_alignParentBottom="true">
<RelativeLayout
android:id="#+id/relativeLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/relativeLayout5"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/element_margin_tiny"
android:layout_marginTop="#dimen/element_margin_tiny">
<TextView
android:id="#+id/textview_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/element_margin_large"
android:layout_marginLeft="#dimen/element_margin_large"
android:gravity="center"
android:text="Position"
android:textColor="#color/black" />
<SeekBar
android:id="#+id/player_seekbar"
style="#style/GreenSeekBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/textview_duration"
android:layout_toRightOf="#+id/textview_position"
android:clickable="true" />
<TextView
android:id="#+id/textview_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/element_margin_large"
android:gravity="center"
android:text="Duration"
android:textColor="#color/black" />
</RelativeLayout>
<LinearLayout
android:id="#+id/relativeLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ToggleButton
android:id="#+id/btnSound"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight="2"
android:paddingLeft="#dimen/element_margin_tiny"
android:scaleType="center"
android:src="#drawable/toggle_sound"
android:textOff=" "
android:textOn=" " />
<ImageButton
android:id="#+id/btnPrevious"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_weight="2"
android:background="#null"
android:scaleType="center"
android:src="#drawable/button_previous" />
<ToggleButton
android:id="#+id/btnPlayPause"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="2"
android:scaleType="center"
android:src="#drawable/togglebutton_playpause"
android:textOff=" "
android:textOn=" " />
<ImageButton
android:id="#+id/btnNext"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/btnRepeat"
android:layout_weight="2"
android:background="#null"
android:scaleType="center"
android:src="#drawable/button_next" />
<ToggleButton
android:id="#+id/btnRepeat"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_weight="2"
android:scaleType="center"
android:src="#drawable/toggle_playlist"
android:textOff=" "
android:textOn=" " />
</LinearLayout>
</RelativeLayout>

Appbar layout not scroll when dyanmically set recyclerview position?

I want to scroll recyclerview with dyanmic position for that i have used below layout but when i am set dynamic position in recyclerview. it is scroll but not above appbar layout.
So how to scroll both recyclerview and appbarlayout when set dynamic position using .
Is it possible parralel scroll if i will set dyamic position.
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
rclTrendDetail.smoothScrollToPosition (3);
}
}, 2000);
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:fbutton="http://schemas.android.com/tools"
>
<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/relativeTop"
android:background="#color/colorWhite"
android:padding="0dp"
>
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsingLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite"
app:contentScrim="#color/colorTransparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite"
android:orientation="vertical"
>
<RelativeLayout
android:id="#+id/relativeProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
>
<RelativeLayout
android:id="#+id/relativeVideo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:visibility="gone"
>
<com.malmstein.fenster.view.FensterVideoView
android:id="#+id/videoplayer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
/>
<LinearLayout
android:id="#+id/linearPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/round_button_progress_bar"
android:gravity="center"
android:orientation="vertical"
>
<ImageView
android:id="#+id/imgShadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="15dp"
android:src="#drawable/ic_play"
/>
</LinearLayout>
<com.spoof.app.customcontrol.CustomButtonRegular
android:id="#+id/gobbleVdoTxt"
style="#style/MyCustomButton"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="25dp"
android:background="#drawable/round_button_progress_bar"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:textAllCaps="false"
android:textColor="#color/colorWhite"
android:textSize="12sp"
android:textStyle="normal"
android:visibility="gone"
/>
<RelativeLayout
android:id="#+id/relativeVideoTime"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:visibility="gone"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_toLeftOf="#+id/btnOnSale"
android:background="#drawable/round_button_progress_bar"
>
<com.spoof.app.customcontrol.CustomTextViewRegular
android:id="#+id/txtUpdateTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:maxLines="1"
android:textAllCaps="false"
android:textColor="#color/colorWhite"
android:textSize="12sp"
android:textStyle="normal"
/>
<app.minimize.com.seek_bar_compat.SeekBarCompat
android:id="#+id/range_slider5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#+id/txtTotalTime"
android:layout_toRightOf="#+id/txtUpdateTime"
android:maxHeight="300sp"
app:progressBackgroundColor="#color/colorWhite"
app:progressColor="#color/colorWhite"
app:thumbColor="#color/colorWhite"
/>
<com.spoof.app.customcontrol.CustomTextViewRegular
android:id="#+id/txtTotalTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:maxLines="1"
android:textAllCaps="false"
android:textColor="#color/colorWhite"
android:textSize="12sp"
android:textStyle="normal"
/>
</RelativeLayout>
<com.spoof.app.customcontrol.CustomButtonRegular
android:id="#+id/btnOnSale"
style="#style/MyCustomButton"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:background="#drawable/round_button_progress_bar"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:text="#string/on_sale"
android:textAllCaps="false"
android:textColor="#color/colorWhite"
android:textSize="13sp"
android:textStyle="normal"
android:visibility="gone"
/>
<LinearLayout
android:id="#+id/linearGift"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:background="#drawable/round_button_progress_bar"
android:gravity="center"
android:visibility="gone"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="8dp"
android:src="#drawable/ic_gift"
/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imgSpoofImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="fitXY"
/>
<RelativeLayout
android:id="#+id/relativeImgCorner"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RelativeLayout>
<com.spoof.app.customcontrol.CustomButtonRegular
android:id="#+id/gobbleImgTxt"
style="#style/MyCustomButton"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="25dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:alpha="0.5"
android:background="#drawable/round_button_progress_bar"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:textAllCaps="false"
android:textColor="#color/colorWhite"
android:textSize="12sp"
android:textStyle="normal"
android:visibility="gone"
/>
</RelativeLayout>
<com.spoof.app.customcontrol.CustomButtonRegular
android:id="#+id/btnOnSaleImage"
style="#style/MyCustomButton"
android:layout_width="80dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="15dp"
android:background="#drawable/round_button_progress_bar"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:text="#string/on_sale"
android:textAllCaps="false"
android:textColor="#color/colorWhite"
android:textSize="12sp"
android:textStyle="normal"
android:visibility="gone"
/>
<LinearLayout
android:id="#+id/linearGiftImage"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="15dp"
android:background="#drawable/round_button_progress_bar"
android:gravity="center"
android:visibility="gone"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="8dp"
android:src="#drawable/ic_gift"
/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:id="#+id/linearTop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical"
>
<com.spoof.app.customcontrol.CustomTextViewLight
android:id="#+id/txtComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginTop="5dp"
android:gravity="left|center_vertical"
android:textAllCaps="false"
android:textColor="#color/colorCrownBlack"
android:textSize="28sp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="80dp"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/imgCrown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:scaleType="fitXY"
/>
<com.spoof.app.customcontrol.CustomTextViewLight
android:id="#+id/txtTotalSpoof"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:textAllCaps="false"
android:textColor="#color/colorCrownBlack"
android:textSize="13sp"
/>
</LinearLayout>
<RelativeLayout
android:id="#+id/relativeMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:id="#+id/relativeImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/imgProfileBG"
android:layout_width="55dp"
android:layout_height="73dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="15dp"
android:scaleType="fitXY"
/>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imgProfile"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="18dp"
app:civ_border_width="4dp"
/>
</RelativeLayout>
<com.spoof.app.customcontrol.CustomTextViewMedium
android:id="#+id/txtUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="#+id/relativeImage"
android:maxLines="1"
android:textAllCaps="false"
android:textColor="#color/colorDarkGray"
android:textSize="18sp"
/>
<com.spoof.app.customcontrol.CustomTextViewRegular
android:id="#+id/txtTrendTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txtUserName"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/relativeImage"
android:maxLines="1"
android:text=""
android:textAllCaps="false"
android:textColor="#color/colorLoginText"
android:textSize="12sp"
/>
<com.spoof.app.customcontrol.CustomButtonRegular
android:id="#+id/btnFollow"
style="#style/MyCustomButton"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/round_button_light_gray"
android:text="#string/following"
android:textAllCaps="false"
android:textColor="#color/colorCrownBlack"
android:textSize="10sp"
android:textStyle="normal"
android:visibility="gone"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:scaleType="fitXY"
android:src="#drawable/ic_separador"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rclTrendDetail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
>
</android.support.v7.widget.RecyclerView>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="#+id/linearShare"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_margin="5dp"
android:gravity="center"
android:layout_alignParentRight="true"
android:layout_below="#+id/relativeTop"
>
<ImageView
android:id="#+id/imgShare"
android:layout_width="30dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:src="#drawable/ico_share"
/>
</LinearLayout>
<RelativeLayout
android:id="#+id/relativeHome"
android:layout_width="61dp"
android:layout_height="61dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:visibility="visible"
>
<info.hoang8f.widget.FButton
android:id="#+id/imgHome"
fbutton:buttonColor="#color/colorDarkGray"
fbutton:cornerRadius="5dp"
fbutton:shadowColor="#color/colorTransparent"
fbutton:shadowEnabled="false"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerInParent="true"
android:visibility="gone"
app:shadowHeight="0dp"
/>
<ImageView
android:id="#+id/imgIconHome"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerInParent="true"
/>
<com.spoof.app.customcontrol.CustomTextViewMedium
android:id="#+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="#color/colorDarkGray"
android:textSize="16sp"
android:visibility="gone"
/>
</RelativeLayout>
</RelativeLayout>
I don't think that's possible, but if you always want to collapse the appbar, regardless of the position that you choose, you could simply call this after every request for the scroll:
appBarLayout.setExpanded(true/false)
This will cause the app bar to collapse.
Further reading:
AppBarLayout.setExpanded(boolean)
Out of scope:
You should split your XML files into more layouts and use <include> tag, this will greatly improve readability of those files.

HorizontalScrollView not working

I am unable to scroll horizontally using HorizontalScrollView, but the same code in other files appears to work fine. I am unable to find an error in this file.
Here is the HorizontalScrollView xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#87E886"
android:orientation="horizontal">
<HorizontalScrollView
android:id="#+id/scrollView1"
android:layout_width="2200dp"
android:layout_height="550dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<!--D2-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageView16"
android:src="#drawable/des1"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageView17"
android:src="#drawable/img_bahay"
android:layout_below="#+id/imageView16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageView18"
android:src="#drawable/des_bahay"
android:layout_below="#+id/imageView17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageView19"
android:layout_below="#+id/imageView18"
android:src="#drawable/desc_bahay"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/xaxaw"
android:src="#drawable/arrow"
></ImageView>
<!--D3-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewa16"
android:src="#drawable/des2"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewa17"
android:src="#drawable/img_chinatown"
android:layout_below="#+id/imageViewa16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewa18"
android:src="#drawable/des_chinatown"
android:layout_below="#+id/imageViewa17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewa19"
android:src="#drawable/desc_chinatown"
android:layout_below="#+id/imageViewa18"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true" />
<!-- <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Estimated Duration:"
android:id="#+id/textView13"
android:textColor="#000000"
android:layout_below="#+id/imageView19"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/textView14"
android:textColor="#000000"
android:layout_below="#+id/textView13"
android:layout_alignParentStart="true"
android:layout_marginLeft="35dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Estimated Distance:"
android:id="#+id/textView15"
android:textColor="#000000"
android:layout_alignTop="#+id/textView13"
android:layout_alignParentEnd="true"
android:layout_marginRight="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/textView16"
android:textColor="#000000"
android:layout_marginLeft="35dp"
android:layout_below="#+id/textView15"
android:layout_alignStart="#+id/textView15"/> -->
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/arrow1"
android:src="#drawable/arrow"
></ImageView>
<!-- D4-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaa16"
android:src="#drawable/des3"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewaa17"
android:src="#drawable/img_goodwill"
android:layout_below="#+id/imageViewaa16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaa18"
android:src="#drawable/des_goodwill"
android:layout_below="#+id/imageViewaa17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewaa19"
android:src="#drawable/desc_goodwill"
android:layout_below="#+id/imageViewaa18"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/arrow53"
android:src="#drawable/arrow"
></ImageView>
<!--D5-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaag16"
android:src="#drawable/des4"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewaag17"
android:src="#drawable/img_chcemetery"
android:layout_below="#+id/imageViewaag16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaag18"
android:src="#drawable/des_chcemetery"
android:layout_below="#+id/imageViewaag17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewaag19"
android:src="#drawable/desc_chcemetery"
android:layout_below="#+id/imageViewaag18"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
Make HorizontalScrollView's with to "wrap_content" and maintain a single child to the HorizontalScrollView i.e.
<HorizontalScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
rest of the code here......
</LinearLayout>
</HorizontalScrollView>
it seems like you have forgotten to end the LinearLayout tag before ending HorizontalScrollView . Your code should look like this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#87E886"
android:orientation="horizontal">
<HorizontalScrollView
android:id="#+id/scrollView1"
android:layout_width="2200dp"
android:layout_height="550dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<!--D2-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageView16"
android:src="#drawable/des1"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageView17"
android:src="#drawable/img_bahay"
android:layout_below="#+id/imageView16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageView18"
android:src="#drawable/des_bahay"
android:layout_below="#+id/imageView17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageView19"
android:layout_below="#+id/imageView18"
android:src="#drawable/desc_bahay"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/xaxaw"
android:src="#drawable/arrow"
></ImageView>
<!--D3-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewa16"
android:src="#drawable/des2"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewa17"
android:src="#drawable/img_chinatown"
android:layout_below="#+id/imageViewa16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewa18"
android:src="#drawable/des_chinatown"
android:layout_below="#+id/imageViewa17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewa19"
android:src="#drawable/desc_chinatown"
android:layout_below="#+id/imageViewa18"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true" />
<!-- <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Estimated Duration:"
android:id="#+id/textView13"
android:textColor="#000000"
android:layout_below="#+id/imageView19"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/textView14"
android:textColor="#000000"
android:layout_below="#+id/textView13"
android:layout_alignParentStart="true"
android:layout_marginLeft="35dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Estimated Distance:"
android:id="#+id/textView15"
android:textColor="#000000"
android:layout_alignTop="#+id/textView13"
android:layout_alignParentEnd="true"
android:layout_marginRight="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/textView16"
android:textColor="#000000"
android:layout_marginLeft="35dp"
android:layout_below="#+id/textView15"
android:layout_alignStart="#+id/textView15"/> -->
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/arrow1"
android:src="#drawable/arrow"
></ImageView>
<!-- D4-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaa16"
android:src="#drawable/des3"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewaa17"
android:src="#drawable/img_goodwill"
android:layout_below="#+id/imageViewaa16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaa18"
android:src="#drawable/des_goodwill"
android:layout_below="#+id/imageViewaa17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewaa19"
android:src="#drawable/desc_goodwill"
android:layout_below="#+id/imageViewaa18"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/arrow53"
android:src="#drawable/arrow"
></ImageView>
<!--D5-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaag16"
android:src="#drawable/des4"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewaag17"
android:src="#drawable/img_chcemetery"
android:layout_below="#+id/imageViewaag16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaag18"
android:src="#drawable/des_chcemetery"
android:layout_below="#+id/imageViewaag17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewaag19"
android:src="#drawable/desc_chcemetery"
android:layout_below="#+id/imageViewaag18"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
ScrollView or in your case HorizontalScrollView can only have one direct child view. Like :
<ScrollView>
<LinearLayout>
// add all the required views here.
</Linearlayout>
</Scrollview>
Although, you can add mulitiple views inside that Linear or any other layout.

moving a specific child layout

i have this layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="#color/black_30">
<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:id="#+id/toolbarAnnouncement"
android:theme="#style/ToolBarStyle"
android:elevation="5dp"
android:textAlignment="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_gravity="center"
android:id="#+id/toolbar_title"
android:textSize="20sp"
android:textStyle="bold"
android:background="#00000000"
android:textColor="#ffffff" />
</android.support.v7.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="15"
android:id="#+id/channelContainer"
android:orientation="horizontal"
android:layout_below="#+id/toolbarAnnouncement"
android:background="#color/black_30">
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="To :"
android:id="#+id/textView16"
android:textSize="20sp"
android:paddingLeft="5dp"
android:layout_gravity="center_vertical" />
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="11"
android:id="#+id/chipViewLayout"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<com.plumillonforge.android.chipview.ChipView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/buttonChannelSelectorAnnouncement"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="left"
android:padding="5dp"
android:minHeight="90dp" />
</RelativeLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:id="#+id/buttonRemoveChannel"
android:background="#android:drawable/ic_menu_close_clear_cancel"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage1"
android:layout_below="#+id/channelContainer"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach1"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#drawable/location" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attached."
android:id="#+id/textViewAttach1"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach1"
android:layout_toEndOf="#+id/imageViewAttach1"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remove"
android:id="#+id/buttonAttach1"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach1"
android:layout_above="#+id/textViewAttach1"
android:layout_alignLeft="#+id/textViewAttach1"
android:layout_toLeftOf="#+id/buttonAttach1"
android:layout_toStartOf="#+id/buttonAttach1"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="100" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage2"
android:layout_below="#+id/attacheImage1"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach2"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#android:drawable/sym_def_app_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attaching..."
android:id="#+id/textViewAtttach2"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach2"
android:layout_toEndOf="#+id/imageViewAttach2"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:id="#+id/buttonAttach2"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach2"
android:layout_above="#+id/textViewAtttach2"
android:layout_alignLeft="#+id/textViewAtttach2"
android:layout_toLeftOf="#+id/buttonAttach2"
android:layout_toStartOf="#+id/buttonAttach2"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="77" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage3"
android:layout_below="#+id/attacheImage2"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach3"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#drawable/icon_admin" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attaching..."
android:id="#+id/textViewAttach3"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach3"
android:layout_toEndOf="#+id/imageViewAttach3"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:id="#+id/buttonAttach3"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach3"
android:layout_above="#+id/textViewAttach3"
android:layout_alignLeft="#+id/textViewAttach3"
android:layout_toLeftOf="#+id/buttonAttach3"
android:layout_toStartOf="#+id/buttonAttach3"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="43" />
</RelativeLayout>
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:inputType="textMultiLine"
android:ems="10"
android:fitsSystemWindows="true"
android:id="#+id/editText"
android:hint="write from here..."
android:gravity="top"
android:padding="5dp"
android:layout_above="#+id/relativeLayout4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_below="#+id/attacheImage3"
android:background="#ffffff" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#color/button_material_light"
android:id="#+id/relativeLayout4">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="Image"
android:id="#+id/buttonAddImage"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="Send"
android:id="#+id/button2"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
and in my layout when i start editing my editText every other layout moves up with keyboard but not the layout that is on bottom(with 2 buttons), i want it to move up too , so that it can be visible while editing my editText
any idea how i can i do this ?? my manifest for my activity :
<activity android:name=".myActivity"
android:theme="#style/AppTheme.NoActionBar"/>
what i actually need looks like this :
SEE THAT THING ON THE BOTTOM IN IOS WE CALL IT INPUT ACCESSORY
and when editing starts :
THAT LAYOUT MOVES UP WITH KEYBOARD
and what i have is this :
and when editing starts :
Try to use that new XML Layout File:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="#color/black_30">
<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:id="#+id/toolbarAnnouncement"
android:elevation="5dp"
android:theme="#style/ToolBarStyle"
android:textAlignment="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_gravity="center"
android:id="#+id/toolbar_title"
android:textSize="20sp"
android:textStyle="bold"
android:background="#00000000"
android:textColor="#ffffff" />
</android.support.v7.widget.Toolbar>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:weightSum="15"
android:id="#+id/channelContainer"
android:orientation="horizontal"
android:layout_below="#+id/toolbarAnnouncement"
android:background="#color/black_30"
android:layout_weight="0.20">
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="To :"
android:id="#+id/textView16"
android:textSize="20sp"
android:paddingLeft="5dp"
android:layout_gravity="center_vertical" />
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="11"
android:id="#+id/chipViewLayout"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<com.plumillonforge.android.chipview.ChipView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/buttonChannelSelectorAnnouncement"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="left"
android:padding="5dp"
android:minHeight="90dp" />
</RelativeLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:id="#+id/buttonRemoveChannel"
android:background="#android:drawable/ic_menu_close_clear_cancel"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage1"
android:layout_below="#+id/channelContainer"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach1"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#drawable/location" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attached."
android:id="#+id/textViewAttach1"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach1"
android:layout_toEndOf="#+id/imageViewAttach1"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remove"
android:id="#+id/buttonAttach1"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach1"
android:layout_above="#+id/textViewAttach1"
android:layout_alignLeft="#+id/textViewAttach1"
android:layout_toLeftOf="#+id/buttonAttach1"
android:layout_toStartOf="#+id/buttonAttach1"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="100" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage2"
android:layout_below="#+id/attacheImage1"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach2"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#android:drawable/sym_def_app_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attaching..."
android:id="#+id/textViewAtttach2"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach2"
android:layout_toEndOf="#+id/imageViewAttach2"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:id="#+id/buttonAttach2"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach2"
android:layout_above="#+id/textViewAtttach2"
android:layout_alignLeft="#+id/textViewAtttach2"
android:layout_toLeftOf="#+id/buttonAttach2"
android:layout_toStartOf="#+id/buttonAttach2"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="77" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/attacheImage3"
android:layout_below="#+id/attacheImage2"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:visibility="gone">
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/imageViewAttach3"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:src="#drawable/icon_admin" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Attaching..."
android:id="#+id/textViewAttach3"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageViewAttach3"
android:layout_toEndOf="#+id/imageViewAttach3"
android:layout_marginLeft="10dp"
android:layout_marginBottom="5dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:id="#+id/buttonAttach3"
android:layout_alignParentTop="false"
android:layout_alignParentRight="true" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/progressBarAttach3"
android:layout_above="#+id/textViewAttach3"
android:layout_alignLeft="#+id/textViewAttach3"
android:layout_toLeftOf="#+id/buttonAttach3"
android:layout_toStartOf="#+id/buttonAttach3"
android:layout_marginRight="5dp"
android:indeterminate="false"
android:progress="43" />
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.70">
<EditText
android:layout_width="match_parent"
android:layout_height="0dp"
android:inputType="textMultiLine"
android:fitsSystemWindows="true"
android:id="#+id/editText"
android:hint="write from here..."
android:gravity="top"
android:padding="5dp"
android:background="#ffffff"
android:ems="10"
android:layout_weight="0.80"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#color/button_material_light"
android:id="#+id/relativeLayout4">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="Image"
android:id="#+id/buttonAddImage"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="Send"
android:id="#+id/button2"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
This is because of you set android:layout_alignParentBottom="true" to relativeLayout4 this won't allow it to scroll upwards. Set Top margin according to your needs or Take Linearlayout and adjust layout by weightsum property and layout_weight property.

Relative layout on wrap content getting fullscreen due to circular dependency

I am pasting the layout below.
It have outer Relative layout, and inside it there are two layouts whose ids are l_first(linear layout) and slider(relative layout). THis slider layout is a layout I want aaligned to the bottom of the device screen and should take the height of the contents(several layouts and views) inside it. bottom of l_first should be positioned between top of the screen and top of slider.
<?xml version="1.0" encoding="utf-8"?>
<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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.example.raw.myapp.NewActivity"
android:background="#f2f2f2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/l_first">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:weightSum="1"
android:id="#+id/slider"
android:background="#e6e6e6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Rental"
android:layout_above="#+id/l_ten_ow"
android:id="#+id/t_rental"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:textColor="#000000"
android:textIsSelectable="true" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ten_ow">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a tenant"
android:id="#+id/btn1"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:textColor="#008000" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a owner"
android:id="#+id/btn2"
android:layout_gravity="center_vertical"
android:layout_weight="0.5" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype_label"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype"
android:paddingBottom="10dp"
android:visibility="visible">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_home"
android:src="#drawable/home1"
android:background="#00000000"
android:nestedScrollingEnabled="false" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_shop"
android:src="#drawable/shop"
android:background="#00000000" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_industry"
android:src="#drawable/industrial"
android:background="#00000000"
android:layout_weight="0.25" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_office"
android:src="#drawable/office"
android:background="#00000000"
android:layout_weight="0.25" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/r_p_subtype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype_label"
android:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="home"
android:id="#+id/textView3"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="shop"
android:id="#+id/sho"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="industrial"
android:id="#+id/ind"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="office"
android:id="#+id/textView6"
android:layout_weight="0.25"
android:textAlignment="center" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_budget"
android:id="#+id/r_p_subtype">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="#+id/btn_oye"
android:id="#+id/l_budget">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Budget"
android:id="#+id/budget"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10k"
android:id="#+id/textView4"
android:layout_below="#+id/budget"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/seekBar"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/budget"
android:layout_toRightOf="#+id/budget"
android:indeterminate="false"
android:progressTint="#39ac73"
android:thumb="#drawable/home" />
</RelativeLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:text="Oye"
android:id="#+id/btn_oye"
android:background="#39ac73"
android:clickable="true"
android:contextClickable="true" />
</RelativeLayout>
To reach your goal you should use a linear layout
make it like this :
<?xml version="1.0" encoding="utf-8"?>
<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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.example.raw.myapp.NewActivity"
android:background="#f2f2f2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/l_first"
android:layout_weight="1">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/slider"
android:orientation="vertical"
android:gravity="bottom"
android:background="#e6e6e6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Rental"
android:layout_above="#+id/l_ten_ow"
android:id="#+id/t_rental"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:textColor="#000000"
android:textIsSelectable="true" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ten_ow">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a tenant"
android:id="#+id/btn1"
android:layout_gravity="center_vertical"
android:layout_weight="0.5"
android:textColor="#008000" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a owner"
android:id="#+id/btn2"
android:layout_gravity="center_vertical"
android:layout_weight="0.5" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_ptype_label"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype"
android:paddingBottom="10dp"
android:visibility="visible">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_home"
android:src="#drawable/home1"
android:background="#00000000"
android:nestedScrollingEnabled="false" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.25"
android:id="#+id/ib_shop"
android:src="#drawable/shop"
android:background="#00000000" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_industry"
android:src="#drawable/industrial"
android:background="#00000000"
android:layout_weight="0.25" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/ib_office"
android:src="#drawable/office"
android:background="#00000000"
android:layout_weight="0.25" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/r_p_subtype"
android:layout_centerHorizontal="true"
android:id="#+id/l_ptype_label"
android:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="home"
android:id="#+id/textView3"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="shop"
android:id="#+id/sho"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="industrial"
android:id="#+id/ind"
android:layout_weight="0.25"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="office"
android:id="#+id/textView6"
android:layout_weight="0.25"
android:textAlignment="center" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/l_budget"
android:id="#+id/r_p_subtype">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="#+id/btn_oye"
android:id="#+id/l_budget">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Budget"
android:id="#+id/budget"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10k"
android:id="#+id/textView4"
android:layout_below="#+id/budget"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/seekBar"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/budget"
android:layout_toRightOf="#+id/budget"
android:indeterminate="false"
android:progressTint="#39ac73"
android:thumb="#drawable/home" />
</RelativeLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:text="Oye"
android:id="#+id/btn_oye"
android:background="#39ac73"
android:clickable="true"
android:contextClickable="true" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
There are two important notes :
Your linear layout should have gravity bottom, it means it calculate the height from the bottom.
the view which you want to get the rest of space should have weight of 1 !!!

Categories

Resources