I'm creating a profile system for users using ListView
and RecyclerView
and I'm not able to make scroll
work. Currently it works like this:
WhenIdonotuseScrollView
,itjustdoesthescrollofLisView
andthetoppartislocked.WhenIuseScrollView
,itstillhasthesameproblem,butitworksfineifIspecifyasizeforlayout_height
otherthanwrap_content
ormatch_parente
,suchas500dp
..butitdoesnottakealltheposts,gettheonesthatgiveaccordingtotheheight.
Ididnotunderstandverywell,IsearchedinsomesitesandIcouldnotsolvethisproblem,IsawinsomeinternationalsitesthatitwouldnotbepossibletouseScrollView
withinListView
andotherssayingthatithad,butdidnotobtainsuccess,Idonotquiteunderstand,cananyonehelpme?
WhatIreallywantisthatthelistscrollalongwiththepageasshownintheimagebelow,inthecaseofInstagram,Facebookandothers.
Scriptfrommyprofile:
<?xmlversion="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="130dp"
cardView:cardBackgroundColor="#FFF"
cardView:cardCornerRadius="4dp"
android:layout_margin="5dp"
android:id="@+id/cardview01"
xmlns:cardView="http://schemas.android.com/apk/res-auto">
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/profileuimage"
android:layout_width="70dp"
android:layout_height="70dp"
app:border_color="#FFF"
android:src="@drawable/placeholder"
app:border_width="2dp"
app:layout_marginLeftPercent="2%"
app:layout_marginTopPercent="2%"
app:layout_marginRightPercent="4%"
app:layout_marginBottomPercent="5%"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ucStatus"
android:background="@drawable/ic_offline"
app:layout_marginLeftPercent="15%"
app:layout_marginTopPercent="35%"/>
<com.addfrases.addfrases.MyCustomTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#4C4C4C"
android:textSize="25dp"
android:id="@+id/profileuname"
app:layout_marginTopPercent="5%"
android:layout_toRightOf="@+id/profileuimage" />
<com.addfrases.addfrases.MyCustomTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ccc"
android:textSize="12dp"
android:id="@+id/profileuregion"
app:layout_marginTopPercent="30%"
android:layout_toRightOf="@+id/profileuimage"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_about"
android:id="@+id/useraboutimg"
android:layout_below="@+id/profileuimage"
app:layout_marginLeftPercent="8%"
app:layout_marginRightPercent="8%" />
<com.addfrases.addfrases.MyCustomTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/profileuserabout"
android:textColor="#696969"
android:textSize="12dp"
app:layout_marginTopPercent="60%"
android:layout_toRightOf="@+id/useraboutimg"
android:allowUndo="false" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/separator"
android:id="@+id/separator"
android:layout_below="@+id/profileuserabout"/>
<Button
android:layout_width="90dp"
android:layout_height="30dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="SEGUIR"
android:textColor="#FFF"
android:background="@drawable/ic_follower"
android:id="@+id/followButton"
android:layout_below="@+id/separator"
android:backgroundTint="#4B7AB2"
app:layout_marginLeftPercent="65%" />
</android.support.percent.PercentRelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
cardView:cardBackgroundColor="#FFF"
cardView:cardCornerRadius="4dp"
android:id="@+id/cardview02"
xmlns:cardView="http://schemas.android.com/apk/res-auto">
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.addfrases.addfrases.MyCustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:id="@+id/totalposts"
android:textSize="20dp"
android:textColor="#414141"
android:text="0"
app:layout_marginLeftPercent="15%"
app:layout_marginTopPercent="20%"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PUBLICAÇÕES"
android:textColor="#4B4F54"
android:textSize="10dp"
app:layout_marginLeftPercent="8%"
android:layout_below="@+id/totalposts"/>
<com.addfrases.addfrases.MyCustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="0"
android:textSize="20dp"
android:textColor="#34373B"
android:id="@+id/totalFollowing"
app:layout_marginLeftPercent="45%"
app:layout_marginTopPercent="20%"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SEGUINDO"
android:textColor="#4B4F54"
android:textSize="10dp"
app:layout_marginLeftPercent="41%"
android:layout_below="@+id/totalFollowing"/>
<com.addfrases.addfrases.MyCustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="0"
android:id="@+id/totalFollowerss"
android:textSize="20dp"
android:textColor="#34373B"
app:layout_marginLeftPercent="80%"
app:layout_marginTopPercent="20%"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SEGUIDORES"
android:textColor="#4B4F54"
android:textSize="10dp"
app:layout_marginLeftPercent="73%"
android:layout_below="@+id/totalFollowing"/>
</android.support.percent.PercentRelativeLayout>
</android.support.v7.widget.CardView>
<view
android:id="@+id/recycler_view"
class="android.support.v7.widget.RecyclerView"
android:layout_width="match_parent"
android:layout_height="453dp"
android:layout_marginTop="5dp"
android:layout_weight="0.31" />
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="200dp"
android:layout_marginTop="250dp"/>
</LinearLayout></ScrollView></FrameLayout>