Expandable Gridview is not showing the full content - android

I am using Expandable GridView which doesn't scroll the whole content if grid items are changed dynamically.
Below is the xml code for main gridview
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="135dp">
<android.support.v4.view.ViewPager
android:id="#+id/pager1"
android:layout_width="match_parent"
android:layout_height="135dp"
android:layout_above="#+id/titles"
android:overScrollMode="never">
</android.support.v4.view.ViewPager>
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/titles"
style="#style/CustomCirclePageIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:padding="5dp" />
</RelativeLayout>
<fone.adipoli.shopping.ExpandableHeightGridView
android:id="#+id/gridView_shopping"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:horizontalSpacing="0dp"
android:listSelector="#android:color/transparent"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="0dp" />
</LinearLayout>
Xml for each Grid item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/cardrow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
card_view:cardCornerRadius="3dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center">
<ImageView
android:id="#+id/img_grid_row1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
/>
</LinearLayout>
<TextView
android:id="#+id/grid_row1_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
/>
<TextView
android:id="#+id/grid_row1_model"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone" />
<TextView
android:id="#+id/grid_row1_price_offr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:id="#+id/grid_row1_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text=""
android:textSize="10sp"
/>
<TextView
android:id="#+id/grid_row1_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text=""
android:textSize="10sp"
android:visibility="gone"
/>
<TextView
android:id="#+id/buy_grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="2dp"
android:text="BUY"
android:padding="10dp"
android:gravity="center"
android:textColor="#color/white"
android:background="#color/blue"
android:textAppearance="? android:attr/textAppearanceSmall"/>
</LinearLayout>
</android.support.v7.widget.CardView>
I tried adding a view in the bottom after GridView ,but it doesn't work out.
Any help would be really thankfull.

Use android.support.v4.widget.NestedScrollView
or
ScrollView
Put your whole Grid items in NestedScrollView, or ScrollView seems to solve your problem.

Related

Last item cut off in ListView

I have ParallaxScrollView which contain two ListViews and also TextViews it's working fine in all the devices but In Tablet(croma CRXT1125Q)the last item cut off in the first ListView, I have made the Tablet layout also but i didn't got any succeed. Please guyz help to solve it.
Help will be appreciate.
My xml looks like as below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical">
<cutomView.ParallaxScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:scrollbars="none"
android:visibility="gone"
app:parallax_factor="1.9">
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="#+id/cardAmount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorGreyBackground"
android:elevation="#dimen/viewmargin"
card_view:cardPreventCornerOverlap="false"
card_view:contentPaddingLeft="#dimen/negContentPadding"
card_view:contentPaddingRight="#dimen/negContentPadding"
card_view:contentPaddingTop="#dimen/negContentPadding">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<RelativeLayout
android:id="#+id/relPackagePhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imgPackage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY" />
<View
android:id="#+id/mTranspherentView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/trending_gradient_shape" />
<cutomView.TextViewAvenirMedium
android:id="#+id/txtPackageName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/mTranspherentView"
android:layout_centerHorizontal="true"
android:maxLines="2"
android:padding="#dimen/small_margine"
android:singleLine="false"
android:text=""
android:textColor="#color/white"
android:textSize="#dimen/small_font" />
<ProgressBar
android:id="#+id/mProgressBar"
style="?android:attr/progressBarStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/margin_leftt"
android:layout_below="#+id/relPackagePhoto"
android:layout_centerVertical="true"
android:orientation="horizontal"
android:weightSum="3">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1">
<cutomView.TextViewAvenirMedium
android:id="#+id/txtOutstandingAmount"
style="#style/CustomBlackTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center"
android:maxLines="2"
android:padding="#dimen/main_margin"
android:singleLine="false"
android:text="#string/total_due_amount"
android:textColor="#color/blue_text"
android:textSize="#dimen/normal_font" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1">
<cutomView.TextViewAvenirMedium
android:id="#+id/txtTotalAmount"
style="#style/CustomBlackTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="#dimen/main_margin"
android:text=""
android:textSize="#dimen/normal_font" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1">
<cutomView.TextViewAvenirMedium
android:id="#+id/txtPayNow"
style="#style/CustomBlackTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#drawable/darkbluebutton"
android:gravity="center"
android:padding="#dimen/main_margin"
android:text="#string/pay_now"
android:textColor="#color/white"
android:textSize="#dimen/normal_font" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/cardAmount"
android:layout_marginTop="#dimen/margin_left"
card_view:cardCornerRadius="0dp"
card_view:cardElevation="2dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/main_margin"
android:layout_marginRight="#dimen/main_margin"
android:orientation="vertical">
<ListView
android:id="#+id/listPaidPayment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:divider="#null"
android:dividerHeight="#dimen/small_margine"
android:fastScrollEnabled="true"
android:listSelector="#android:color/transparent"
android:scrollbars="none"
android:smoothScrollbar="true" />
<View
android:id="#+id/viewSeperator"
android:layout_width="match_parent"
android:layout_height="#dimen/view_width"
android:layout_marginLeft="#dimen/margin_top_"
android:layout_marginRight="#dimen/main_margin"
android:layout_marginTop="#dimen/main_margin"
android:background="#color/darkGreyCardBg"
android:visibility="gone" />
</LinearLayout>
<cutomView.TextViewAvenirMedium
android:id="#+id/txtDueAmount"
style="#style/CustomBlackTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/margin_left"
android:background="#color/footertext"
android:gravity="center"
android:padding="#dimen/main_margin"
android:text="#string/total_due_amount"
android:textColor="#color/white"
android:textSize="#dimen/normal_font" />
<ListView
android:id="#+id/listDuePayment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/main_margin"
android:layout_marginRight="#dimen/main_margin"
android:cacheColorHint="#00000000"
android:divider="#null"
android:dividerHeight="#dimen/small_margine"
android:fastScrollEnabled="true"
android:listSelector="#android:color/transparent"
android:scrollbars="none"
android:smoothScrollbar="true" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</cutomView.ParallaxScrollView>
</LinearLayout>

Making list view strech entire screen height

I have a list view design for a recipes app. Each item consists of a image, title, description and number of calories. My problem is that it doesnt fill the entire screen, but instead it gives a scrollbar on the right.
How can I make it fill the screen?
Also, is there a better way of showing the list items without using tables?
list.xml:
<FrameLayout 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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadingEdgeLength="0dp"
android:fillViewport="true"
android:overScrollMode="never"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="#+id/listViewRecipes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="1dp"
android:padding="10dp"></ListView>
</RelativeLayout>
</ScrollView>
</FrameLayout>
list_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="8dp"
android:fadingEdgeLength="0dp"
android:fillViewport="true"
android:overScrollMode="never"
android:scrollbars="none">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow
android:id="#+id/tableRow1">
<!-- Image -->
<ImageView
android:id="#+id/listViewRecipeImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
android:overScrollMode="never"
app:srcCompat="#drawable/img_pixel" />
<!-- //Image -->
<!-- Title, Introduction -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="6dp"
android:fadingEdgeLength="0dp"
android:fillViewport="true"
android:overScrollMode="never"
android:scrollbars="none">
<TextView
android:id="#+id/listViewRecipeTitle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/colorBlack"/>
<TextView
android:id="#+id/listViewRecipeIntroduction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/colorBlack"
android:text="Introduction"/>
</LinearLayout>
<!-- //Title, Introduction -->
<!-- Numbers -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="6dp">
<TableRow>
<TextView
android:id="#+id/textViewServingCalories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/colorDarkGray"
android:text="xx" />
<TextView
android:id="#+id/textViewServingCaloriesKcal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/colorDarkGray"
android:layout_marginLeft="6dp"
android:text="#string/kcal_lowercase" />
</TableRow>
</TableLayout>
<TextView
android:id="#+id/textViewServingCaloriesKcalPerServing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/colorDarkGray"
android:text="#string/per_serving_lowercase" />
</LinearLayout>
<!-- //Numbers -->
</TableRow>
</TableLayout>
</LinearLayout>
This is a modify version of your code. You need to remove the outer scrollView since ListView is scrollable
<FrameLayout 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="match_parent">
<ListView
android:id="#+id/listViewRecipes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="1dp"
android:padding="10dp">
</ListView>
</FrameLayout>
I have also remove the table layout and replace it with LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="wrap_content"
android:orientation="horizontal"
android:padding="8dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="3">
<ImageView
android:id="#+id/listViewRecipeImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
android:overScrollMode="never"
app:srcCompat="#drawable/add" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:orientation="vertical">
<TextView
android:id="#+id/listViewRecipeTitle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/colorBlack"/>
<TextView
android:id="#+id/listViewRecipeIntroduction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/colorBlack"
android:text="Introduction"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textViewServingCalories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/colorPrimary"
android:text="xx" />
<TextView
android:id="#+id/textViewServingCaloriesKcal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/colorPrimary"
android:layout_marginLeft="6dp"
android:text="Carolies" />
</LinearLayout>
<TextView
android:id="#+id/textViewServingCaloriesKcalPerServing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/colorPrimary"
android:text="Per Server" />
</LinearLayout>
Listview contains an inner scrollview. Just remove the scrollview.
either use that RelativeLayout or just the Listview on your frame. And match parent it.

Android, layout_above not working

I want to display some text in the middle of the screen, below header and above footer. Since this text is very long I nested it in ScrollView. I have tried a number of solutions: this, this, this, this, and a bunch more...
At first I had a problem of the two relative_layouts overlapping and text being cut of. The most accepted answer is to use layout_above and layout_below, but when I use layout_above, the text is never displayed.
This is what my xml looks like:
<?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:orientation="vertical">
<RelativeLayout
android:id="#+id/linear_layout_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/gray"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="3">
<ImageView
android:id="#+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="10dp"
android:contentDescription="#string/profile_photo"
android:src="#drawable/default_profile"
tools:ignore="RtlHardcoded" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_above="#+id/ln_layout_footer"
android:layout_below="#+id/linear_layout_header">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
tools:ignore="UselessParent">
<TextView
android:id="#+id/meetupDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="#string/text"/>-
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/ln_layout_footer"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingTop="10dp">
<LinearLayout
android:id="#+id/ln_layout"
android:layout_width="fill_parent"
android:background="#color/gray"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<TextView
android:id="#+id/red"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/red" />
<TextView
android:id="#+id/blue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#color/white"
android:layout_weight="1"
android:gravity="center"
android:text="#string/blue" />
<TextView
android:id="#+id/green"
android:layout_width="match_parent"
android:textColor="#color/white"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/green" />
</LinearLayout>
</RelativeLayout>
in your ln_layout_footer
set android:layout_height="wrap_content"
Edited
<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:orientation="vertical">
<RelativeLayout
android:id="#+id/linear_layout_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/dark_gray_pressed"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="3">
<ImageView
android:id="#+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="10dp"
android:contentDescription="#string/action_settings"
android:src="#drawable/img_splash_logo"
tools:ignore="RtlHardcoded" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/ln_layout_footer"
android:layout_below="#+id/linear_layout_header">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
tools:ignore="UselessParent">
<TextView
android:id="#+id/meetupDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="#string/txt_price" />-
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/ln_layout_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingTop="10dp">
<LinearLayout
android:id="#+id/ln_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/dark_gray"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<TextView
android:id="#+id/red"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/txt_quantity"
android:textColor="#color/white" />
<TextView
android:id="#+id/blue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/txt_material"
android:textColor="#color/white" />
<TextView
android:id="#+id/green"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="#string/msg_enter_user_name"
android:textColor="#color/white" />
</LinearLayout>
</RelativeLayout>
In you layout using two properties that why it doesn't work. So you can remove one properties here is your working code
<RelativeLayout
android:id="#+id/scrollViewAndStuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/linear_layout_header">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp">
<TextView
android:textColor="#000"
android:id="#+id/meetupDescription"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:text="#string/text" />-
</ScrollView>
</RelativeLayout>
you can use this android:layout_below="#+id/linear_layout_header or this android:layout_above="#+id/ln_layout_footer, one property at a time. or simply copy and past

Fragment page is not scrolling in android

I have one fragment but its not vertically scrolling . My XML code is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#E6E6E6">
<!-- Top Sliding Banners -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="220dip" >
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom|left"
android:padding="10dip"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="Trending"
android:textColor="#000"
android:textSize="20sp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textview"
android:scrollbars="none" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/popular_textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="Popular"
android:textColor="#000"
android:textSize="20sp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/popular_recycler_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/popular_textview"
android:scrollbars="none" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/featured_textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="Featured"
android:textColor="#000"
android:textSize="20sp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/featured_recycler_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/featured_textview"
android:scrollbars="none" />
</LinearLayout>
I have tried all solution of stackoverflow.My code have three recyclerview and they work fine .Only problem is than page is not vertically scrollable.
try using NestedScrollView as parent tag for this layout.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
remember to keep only one direct child for nestedScroll view.

Three children on RelativeLayout does not get place to be shown

I am trying to show four direct children on a Relative Layout where first one is a EdiText (in 'gone' visibility) and second one is LinearLayout with a TextView and ImageView and third is a ListView and fourth is another LinearLayout.
ListView gets over all children. I am posting below the code.
<?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:id="#+id/scrollview"
android:background="#drawable/bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.antoinecampbell.gcmdemo.GcmActivity$PlaceholderFragment">
<EditText
android:id="#+id/recepient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:imeOptions="actionSend"
android:inputType="phone"
android:visibility="invisible">
<requestFocus />
</EditText>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/recepient" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:text="Preview"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone"/>
<ImageView android:id="#+id/imageShow"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/abs__ic_go"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
</LinearLayout>
<ListView android:id="#+id/listMessages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayout1"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:listSelector="#00000000"
/>
<LinearLayout
android:id="#+id/bottomview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_below="#+id/listMessages"
android:layout_alignParentBottom="true"
android:visibility="gone"
android:background="#FFFFFF">
<com.rockerhieu.emojicon.EmojiconEditText
android:id="#+id/name_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:layout_weight="1"
android:hint="#string/enter_message_text"
android:imeOptions="actionSend"
android:inputType="text"
android:layout_gravity="center_vertical"
android:visibility="visible"/>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/frameView"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<fragment
android:id="#+id/emojicons"
android:layout_width="match_parent"
android:layout_height="220dp"
class="com.rockerhieu.emojicon.EmojiconsFragment"/>
</LinearLayout>
<ImageButton
android:id="#+id/send_message_button"
android:background="#drawable/angry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:visibility="visible"/>
</LinearLayout>
</RelativeLayout>
Now I tried using LinearLayout with scrollview inside it, it's now not scrolling the listview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/recepient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:imeOptions="actionSend"
android:inputType="phone"
android:visibility="invisible">
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:text="Preview"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone"/>
<ImageView android:id="#+id/imageShow"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/abs__ic_go"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
<ListView android:id="#+id/listMessages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayout1"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:listSelector="#00000000"
/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/bottomview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_below="#+id/listMessages"
android:layout_alignParentBottom="true"
android:visibility="visible"
android:background="#FFFFFF">
<com.rockerhieu.emojicon.EmojiconEditText
android:id="#+id/name_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:layout_weight="1"
android:hint="#string/enter_message_text"
android:imeOptions="actionSend"
android:inputType="text"
android:layout_gravity="center_vertical"
android:visibility="visible"/>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/frameView"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<fragment
android:id="#+id/emojicons"
android:layout_width="match_parent"
android:layout_height="220dp"
class="com.rockerhieu.emojicon.EmojiconsFragment"/>
</LinearLayout>
<ImageButton
android:id="#+id/send_message_button"
android:background="#drawable/angry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:visibility="visible"/>
</LinearLayout>
</LinearLayout>
The ListView will go over other elements because you've not given it any relative positions. In a relative layout, every element will be default appear at (0,0) (ie the top left corner of the view) unless it's given a layout_below, layout_alignBottom etc parameter to determine where it's drawn.
So in this case, you 'resumably want the ListView to have android:layout_below="#id/LinearLayout1 and the bottomview similarly android:layout_below="#id/listMessages.
Here is the xml as per your requirement.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center" >
<EditText
android:id="#+id/edNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:inputType="phone"
android:visibility="gone" />
<LinearLayout
android:id="#+id/llLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edNumber"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="linear layout text" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
</LinearLayout>
<ListView
android:id="#+id/lvList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/llBottom"
android:layout_below="#id/llLayout" >
</ListView>
<LinearLayout
android:id="#+id/llBottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#ababab"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Bottom Bar text" />
</LinearLayout>
</RelativeLayout>

Categories

Resources