Android Scrollview Not working inside Drawer Layout - android

I have Scroll view inside Custom Drawer Layout The scroll view not working.
The view consists of relative layout of image slider and linear layout filled row by row later. Although the property of the height is wrap_content it doesn't work.
Here's the layout xml file`
<com.example.msamy.almishkah.HomePage.MyDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="vertical"
android:id="#+id/scrollFView">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.daimajia.slider.library.SliderLayout
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="220dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp" />
<com.daimajia.slider.library.Indicators.PagerIndicator
android:id="#+id/custom_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginBottom="50dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="215dp"
android:gravity="center"
custom:selected_color="#ffa500"
custom:selected_height="10dp"
custom:selected_padding_left="4dp"
custom:selected_padding_right="4dp"
custom:selected_width="10dp"
custom:shape="rect"
custom:unselected_color="#ffffff"
custom:unselected_height="10dp"
custom:unselected_padding_left="4dp"
custom:unselected_padding_right="4dp"
custom:unselected_width="10dp" />
<TextView
android:id="#+id/textSlider"
android:layout_width="220dp"
android:layout_height="60dp"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="140dp"
android:background="#ffffff"
android:textColor="#color/colorPrimary"
android:textSize="18sp" />
<Button
android:id="#+id/sliderButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="140dp"
android:layout_marginRight="140dp"
android:layout_marginTop="170dp"
android:fontFamily="sans-serif"
android:text="More"
android:textColor="#ffa500"
android:textSize="18sp" />
</RelativeLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/Homeisa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</ScrollView>
<ListView
android:id="#+id/lv_sliding_menu"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#FFFFFF"
android:choiceMode="singleChoice">
</ListView>
</com.example.msamy.almishkah.HomePage.MyDrawerLayout>
` the relative layout is for image slider in the top of the page and the Layout below is filled pro-grammatically with linear layouts which is bigger than the height of the page.the list view is for the sliding menu of the drawer layout.

Related

Put Button at bottom of scrollview or bottom of screen

I have a problem with layout of my Application.
I'm trying to do a layout like Trello (screen of trello layout for example get from google)
But I have a problem with the Button at the Bottom of ScrollView:
Now my app is something like:
So How you can see, the button I always at the bottom of display.
I would like create a Header section, body section with Scrollview and recycler view and Footer with action button.
For now my xml app is:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/card_view"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/header_title"
style="#style/card_header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:text="title"
/>
<TextView
android:id="#+id/header_subtitle"
style="#style/card_header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/header_title"
android:text="subtitle" />
<ImageButton
android:id="#+id/context_menu"
android:layout_width="80dp"
android:layout_height="24dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_gravity="right"
android:background="#android:color/transparent"
android:clickable="true"
android:src="#drawable/ic_more_vert_black_16dp"
/>
</RelativeLayout>
<android.support.v4.widget.NestedScrollView
android:layout_below="#+id/header"
android:layout_above="#+id/button_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/header"
/>
</android.support.v4.widget.NestedScrollView>
<Button
android:id="#+id/button_action"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="#string/button_action"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
The parent Layout that contain a "list of block" is
<HorizontalScrollView
android:id="#+id/horizontalScrollFather"
android:orientation="horizontal"
android:fillViewport="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/list_blocks"
android:layout_width="wrap_content"
android:layout_height="match_parent"
/>
</RelativeLayout>
</HorizontalScrollView>
EDIT
I have tried to make a modify to my xml with:
<android.support.v4.widget.NestedScrollView
android:id="#+id/myNestedScrollView"
android:layout_below="#+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</android.support.v4.widget.NestedScrollView>
<Button
android:id="#+id/button_action"
android:layout_below="#+id/myNestedScrollView" <!-- as suggested -->
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/button_action"
/>
But the problem now is the scrollview with recycler hides the Button:
How Can I replicate the layout ?
Use this code
<android.support.v4.widget.NestedScrollView
android:id="#+id/myNestedScrollView"
android:layout_below="#+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v4.widget.NestedScrollView>
<Button
android:id="#+id/button_action"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/myNestedScrollView"
android:text="#string/button_action"/>
Changes
Don't do alignParentBottom on Button and don't put NestedScrollView above Button instead put Button below NestedScrollView
And there is no need to use android:layout_below="#id/header" in RecyclerView

Scrollview hiding the textview text in landscape mode

I am trying to use the scrollview to make the textview wrapped within it scrollable.
I am using the grid layout and am able to position the items as I need to, particularly the long text block, wrapped in a scroll view (the text under the big heading).
However, upon rotating , the long text block disappears completely and I have to keep scrolling it up to make it visible. I need it to be visible as expected when in landscape mode.
landscape mode, now visible after swiping up
This is my 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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/toolbar" android:id="#+id/toolbar"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_marginTop="20dp"
android:id="#+id/articlesummaryimageview"
android:layout_below="#id/toolbar"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/articlesummaryheadingtextview"
android:layout_below="#id/articlesummaryimageview"
android:layout_centerHorizontal="true"
android:textSize="26dp"
android:textStyle="bold"
android:textAlignment="center"
android:layout_marginTop="20dp"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/articlesummaryscreenscrollview"
android:layout_below="#id/articlesummaryheadingtextview"
android:fillViewport="false"
android:layout_above="#+id/showfullarticlebutton"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/articlesummarytextview"
android:textSize="18dp"
android:textAlignment="center"
android:padding="5dp"
/>
</ScrollView>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/showfullarticlebutton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:textSize="18dp"
android:text="Full Article"
style="#style/AlertDialog.AppCompat.Light"
/>
</RelativeLayout>
Thank you
You're going to have to make your whole layout scrollable or come up with a different design. To make the whole layout scrollable, put the RelativeLayout inside the ScrollView and set the layout_height for the ScrollView to be wrap_content.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:id="#+id/articlesummaryscreenscrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<include
layout="#layout/toolbar"
android:id="#+id/toolbar"
/>
<ImageView
android:id="#+id/articlesummaryimageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/toolbar"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<TextView
android:id="#+id/articlesummaryheadingtextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/articlesummaryimageview"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:textAlignment="center"
android:textSize="26dp"
android:textStyle="bold"
/>
<TextView
android:id="#+id/articlesummarytextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textAlignment="center"
android:textSize="18dp"
android:layout_above="#+id/showfullarticlebutton"
android:layout_below="#id/articlesummaryheadingtextview"
/>
<Button
android:id="#+id/showfullarticlebutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Full Article"
android:textSize="18dp"
style="#style/AlertDialog.AppCompat.Light"
/>
</RelativeLayout>
If your business rules don't allow for the entire layout to be scrollable, what you can do is put your ScrollView as the first layout in the XML and adjust your other views layout_above and layout_below to that initial one (basically making that the view that is always shown and everything else adjust around it).
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ScrollView
android:id="#+id/articlesummaryscreenscrollview"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="#+id/showfullarticlebutton"
android:fillViewport="false"
>
<TextView
android:id="#+id/articlesummarytextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textAlignment="center"
android:textSize="18dp"
/>
</ScrollView>
<TextView
android:id="#+id/articlesummaryheadingtextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/articlesummaryscreenscrollview"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:textAlignment="center"
android:textSize="26dp"
android:textStyle="bold"
/>
<ImageView
android:id="#+id/articlesummaryimageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/articlesummaryheadingtextview"
android:layout_below="#id/toolbar"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<Button
android:id="#+id/showfullarticlebutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Full Article"
android:textSize="18dp"
style="#style/AlertDialog.AppCompat.Light"
/>
</RelativeLayout>
1. Add RelativeLayout as a direct child of ScrollView and put TextView inside it.
2. Use attributge android:fillViewport="true" to ScrollView.
Try this:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/toolbar" android:id="#+id/toolbar"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_marginTop="20dp"
android:id="#+id/articlesummaryimageview"
android:layout_below="#id/toolbar"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/articlesummaryheadingtextview"
android:layout_below="#id/articlesummaryimageview"
android:layout_centerHorizontal="true"
android:textSize="26dp"
android:textStyle="bold"
android:textAlignment="center"
android:layout_marginTop="20dp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/articlesummaryscreenscrollview"
android:layout_below="#id/articlesummaryheadingtextview"
android:fillViewport="true"
android:layout_above="#+id/showfullarticlebutton">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/articlesummarytextview"
android:textSize="18dp"
android:textAlignment="center"
android:padding="5dp"
android:text="this is a text"/>
</RelativeLayout>
</ScrollView>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/showfullarticlebutton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:textSize="18dp"
android:text="Full Article"
style="#style/AlertDialog.AppCompat.Light" />
</RelativeLayout>

Alternating Visibilities of Views in Bottom of Relative Layout

I have a relative layout and want to put a view (a AdMob view) on the bottom of the layout. This works fine, like so:
Now, if there is no internet connection, I want to replace the AdMob view with a placeholder ImageView. I want to do this by setting the AdMob view visibility to GONE and set the ImageView visibility to VISIBLE. But the result does not look right - the ImageView is now on top red and green parts, as shown below:
Here is the layout xml code:
<RelativeLayout 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"
android:layout_margin="#dimen/activity_margin"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/app_bar_main">
<LinearLayout
android:id="#+id/main"
android:layout_above="#id/ad_view"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:background="#AA9999"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="LEFT SIDE"
/>
<TextView
android:text="some long text here"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:layout_width="#dimen/activity_margin"
android:layout_height="match_parent" />
<LinearLayout
android:background="#99AA99"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RIGHT SIDE" />
<TextView
android:text="MORE LONG TEXT HERE"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/ad_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:visibility="gone"
app:adSize="BANNER"
app:adUnitId="#string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
<ImageView
android:background="#000000"
android:id="#+id/ad_placeholder"
android:src="#drawable/ad_placeholder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:visibility="visible" />
</RelativeLayout>
I tried to put both the ImageView and AdMob view in one linear layout (call this bottom linear layout), and have the main linear layout (#id/main) use a "layout_above" on the bottom linear layout. But the code won't compile.
Any suggestions?
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/app_bar_main">
<!--Using relative layout to get the ad align property, could not get linear layout to work properly.-->
<LinearLayout
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/adMob_container_my"
android:layout_alignParentTop="true"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="#AA9999"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="LEFT SIDE"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="some long text here"/>
</LinearLayout>
<View
android:layout_width="10dp"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="#99AA99"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RIGHT SIDE"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="MORE LONG TEXT HERE"/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/adMob_container_my"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<com.google.android.gms.ads.AdView
android:id="#+id/ad_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="invisible"
app:adSize="BANNER">
</com.google.android.gms.ads.AdView>
<ImageView
android:id="#+id/ad_placeholder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#000000"
android:src="#drawable/ic_pango_logo_title"
android:visibility="visible"/>
</RelativeLayout>
</RelativeLayout>
you have forgotten the '+' sign in here: android:layout_above="#+id/adMob_container_my"

Match parent for viewpager inside scrollview not working

I'm trying to put the view pager inside a table row and I set the view pager layout height match parent. the result is that the view pager has no height at all. I have to set the layout height in dp so that the view pager can have a height. But what I'm inflating inside the view pager is dynamic, therefore I can't set the height inside the xml. The scrollview already fill the screen, but the viewpager doesn't have any height at all. Is there any way to get around this? (the view pager that has a problem is the one that has id pager_problem)
EDIT :
okay, now after I change it, the viewpager exists, but only as big as the screen, I want to make the content inside the viewpager scrollable if the fragment content is long (all the layout scrollable, not only the fragment in view pager)
<?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">
<com.emilsjolander.components.StickyScrollViewItems.StickyScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TableRow>
<android.support.v4.view.ViewPager
android:id="#+id/pager_image"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="100dp" />
</TableRow>
<TableRow android:tag="sticky">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="50dp"
android:id="#+id/tab"
android:tag="sticky"
android:layout_below="#id/pager_image"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/frame_general_tab"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp"
android:text="GENERAL"/>
</LinearLayout>
<LinearLayout
android:id="#+id/frame_detail_tab"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:background="#color/gray_F2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp"
android:text="DETAIL"/>
</LinearLayout>
<LinearLayout
android:id="#+id/frame_foto_tab"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:background="#color/gray_F2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp"
android:text="FOTO"/>
</LinearLayout>
</LinearLayout>
</TableRow>
<TableRow>
<!--<LinearLayout android:id="#+id/page_container"
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginBottom="70dp"
android:layout_height="match_parent">
</LinearLayout>-->
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_marginBottom="70dp"
android:layout_height="match_parent"/>
</TableRow>
</TableLayout>
</LinearLayout>
</com.emilsjolander.components.StickyScrollViewItems.StickyScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content">
<GridLayout
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:columnCount="2"
android:background="#color/gray_F2"
android:rowCount="3"
android:orientation="vertical"
android:layout_height="70dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="20dp"
android:textSize="15dp"
android:layout_gravity="right"
android:textColor="#color/gray_72"
android:text="Harga mulai"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:textSize="20dp"
android:layout_gravity="right"
android:text="Rp 10.560.000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="20dp"
android:textSize="15dp"
android:layout_gravity="right"
android:textColor="#color/gray_72"
android:text="per kamar per malam"/>
<Button android:layout_width="150dp"
android:layout_marginLeft="20dp"
android:layout_height="match_parent"
android:layout_rowSpan="3"
android:background="#color/traveloka_button_orange"
android:textColor="#color/white"
android:layout_margin="10dp"
android:text="LIHAT KAMAR"/>
</GridLayout>
</RelativeLayout>
</RelativeLayout>
You need to set android:fillViewport="true" to the scrollview
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent"

Alignment layout at the bottom with listview

I've a framelayout with a listview and a linearlayout (bottom bar) at the bottom of this.
When expand the listview, I can't scroll properly because the linearlayout at the bottom has covered the child of listview.
I don't understand where is the problem...I would like separate the bottom bar from the listview.
This is my layout (possibly, can you optimize this layout?):
<FrameLayout 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.robertot.timereport.com.robertot.timereport.pages.WeeklyStatFragment">
<RelativeLayout
android:id="#+id/rlList"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listWeek"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:layout_gravity="bottom"
style="#android:style/Widget.Holo.Light.ActionBar.Solid">
<Spinner
android:id="#+id/spnYearW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"/>
<Spinner
android:id="#+id/spnMonthW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"/>
<ImageButton
android:id="#+id/btnFilter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_search"
android:background="#null"
android:layout_weight="1"
android:layout_gravity="center_vertical"/>
</LinearLayout>
</FrameLayout>
thanks!!
The problem is your FrameLayout doesn't prevent your Views from overlapping, which is why your ListView appears below it. One solution, that wouldn't require you to change much, would be to put your bottom LinearLayout inside your RelativeLayout and use the alignParentBottom and layout_above attributes to position things:
<FrameLayout 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.robertot.timereport.com.robertot.timereport.pages.WeeklyStatFragment">
<RelativeLayout
android:id="#+id/rlList"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listWeek"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/bottom_linear" />
<LinearLayout
android:id="#+id/bottom_linear"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
style="#android:style/Widget.Holo.Light.ActionBar.Solid">
<Spinner
android:id="#+id/spnYearW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"/>
<Spinner
android:id="#+id/spnMonthW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"/>
<ImageButton
android:id="#+id/btnFilter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_search"
android:background="#null"
android:layout_weight="1"
android:layout_gravity="center_vertical"/>
</LinearLayout>
</RelativeLayout>
</FrameLayout>

Categories

Resources