I have a problem with the items, when I move the list, it also moves the part arrives, that makes up space on the screen, I want it to go away when the list to move and to appear when the stroll is in the part of arrives, thank you very much! Sorry for the translation but is cast with a translator.
<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"
tools:context="com.app.flyforo.MainActivity" >
<LinearLayout
android:id="@+id/contentUser"
android:layout_width="fill_parent"
android:layout_height="90dp"
android:background="@drawable/banner" >
<ImageView
android:id="@+id/imageUser"
android:layout_width="80dp"
android:layout_height="60dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="Flyforo"
android:textColor="#fff"
android:textSize="11sp" />
<TextView
android:id="@+id/userTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginLeft="-40dp"
android:layout_marginRight="28dp"
android:layout_marginTop="20dp"
android:text="Flyforo"
android:textColor="#fff"
android:textSize="17sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/contentSeguidores"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/contentUser" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.74"
android:background="#FBFBFB"
android:orientation="vertical" >
<TextView
android:id="@+id/numseguidores"
android:layout_width="215dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:gravity="center"
android:text="4"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:layout_width="215dp"
android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:gravity="center"
android:text="Seguidores"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/menu"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/contentSeguidores"
>
<LinearLayout
android:layout_width="160dp"
android:layout_height="match_parent"
android:background="@drawable/border2"
android:orientation="vertical" >
<TextView
android:id="@+id/buttoninicio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Inicio"
android:textSize="17sp" />
</LinearLayout>
<LinearLayout
android:layout_width="160dp"
android:layout_height="match_parent"
android:background="@drawable/border2"
android:orientation="vertical" >
<TextView
android:id="@+id/buttonposts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="17sp"
android:text="Posts" />
</LinearLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/loading"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true" />
<Button
android:id="@+id/button1"
android:layout_width="50dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_below="@+id/contentUser"
android:layout_marginRight="10dp"
android:drawableLeft="@drawable/ic_action_add_person"
android:layout_marginTop="7dp"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#fff"
android:background="@drawable/button_confirm"
android:text="" />
<ListView
android:id="@+id/profileList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/menu"
>
</ListView>
</RelativeLayout>
I suppose you mean you have content above the ListView, and when you scroll the ListView, you want the content that's above it to scroll off the screen too. If this is describes your issue, continue reading!
You'll want to wrap the content above the ListView in its own XML file, inflate it as a single ViewGroup, and then add that ViewGroup as a header on the ListView.
Your view hierarchy looks as follows:
RelativeLayout
LinearLayout=contentUser
LinearLayout=contentSeguidores
LinearLayout=menu
ProgressBar
Button
ListView
/RelativeLayout
If this is in a file called activity_list.xml
, then you can copy the contents to another file called view_list_header.xml
in your layout directory. In this copied file, delete the ListView, and in activity_list.xml
delete everything except the ListView, so that the file structures will be as follows:
activity_list.xml
:
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/profileList"
android:layout_width="match_parent"
android:layout_height="match_parent" />
and view_list_header.xml
:
RelativeLayout
LinearLayout=contentUser
LinearLayout=contentSeguidores
LinearLayout=menu
ProgressBar
Button
/RelativeLayout
In your Activity, or wherever you set up your ListView, you will have had something similar to:
...
setContentView(R.layout.activity_list);
ListView listView = (ListView) findViewById(R.id.profileList);
listView.setAdapter(...);
...
Now, you will need to inflate the header, and add it to ListView before setting your adapter:
...
setContentView(R.layout.activity_list);
ListView listView = (ListView) findViewById(R.id.profileList);
View headerView = getLayoutInflater().inflate(R.layout.view_header_list, listView, false);
listView.addHeaderView(headerView);
listView.setAdapter(...);
...