Make content of ScrollView scroll behind a LinearLayout with a transparent background - android

I have a vertical ScrollView with some ImageViews that I can scroll up and down. At the bottom of my application I have a footer consisting of a LinearLayout with a partly transparent background image (png). How do I achieve the following behavior?
Consider the following layout
<LinearLayout blah blah... >
<RelativeLayout
android:id="#+id/guesses_scroll_view_holder"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:id="#+id/guesses_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bgrepeat"
android:scrollbarStyle="outsideOverlay"
android:layout_above="#+id/footer" >
<LinearLayout
android:id="#+id/guesses"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bgrepeat"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/peg_picker_bgrepeat"
android:orientation="vertical" >
< some footer content />
</LinearLayout>
</RelativeLayout></LinearLayout>
What I got at the moment is something that looks like this
Since my background image peg_picker_bgrepeat is not rectangular, I get an ugly border above the ScrollView. How can I make the contents "scroll behind" the footer?

Related

scrollview not growing vertically when content size increases beyond screen size

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/notesLayoutManagerScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fffaaa"
android:fillViewport="true"
tools:context="com.gp.app.professionalpa.layout.manager.NotesLayoutManagerActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/notesLayoutManagerParentLinearLayout"
android:orientation="horizontal"
android:background="#ffffff"
android:baselineAligned="false">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="0dip"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_marginRight="1dip"
android:background="#ffffff">
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="0dip"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_marginLeft="1dip"
android:background="#ffffff">
</LinearLayout>
</LinearLayout>
</ScrollView>
with the above layout.xml code scroll bar does not appear when the content of the linear layout with ids "linearLayout1" and "linearLayout2" grow in size vertically.
Please suggest how can i bring scrollbar in my activity view when the size of "linearLayout1" and "linearLayout2" grows beyond parent size. I want single scroll bar for my complete activity view and not separate scroll bars for "linearLayout1" and "linearLayout2".
ScrollView should have a layout_height of wrap_content as well.

ScrollView throws bottom views out

I have a LinearLayout with a ScrollView inside and a checkbox underneath the scrollview. Whenever i put alot of text in the scrollview, it will expand through the whole screen and kick out the bottom checkbox view. How do i prevent that from happening?
Basically, i want the checkbox to always be right underneath the scrollview. I also want the scrollview to shrink and expand depending on its text. When theres alot of text inside, it should expand to the point where the checkbox is still visible at the bottom of the screen.
It should look like this:
Where the filled ScrollView should have a scroller if the text is too much, rather than kicking out the checkbox from the screen
Help!
My layout looks like:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- TextView inside --->
</ScrollView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="80dp"
android:gravity="top"
android:orientation="horizontal" >
<!-- CheckBox inside --->
</RelativeLayout>
</LinearLayout>
Dont worry about the syntax, or all the stuff that are inside, I wrote this quick because the code inside is really long and unnecessary!
Try this layout :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1">
<!-- TextView inside --->
</ScrollView>
<!-- CheckBox Here --->
</LinearLayout>
Let's start simple. Try replacing your parent LinearLayout with a RelativeLayout. If this doesn't work, you may have to fix the height of ScrollView to some fixed height using weight, or pixels (which is non-ideal):
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- TextView inside --->
</ScrollView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="80dp"
android:gravity="top"
android:orientation="horizontal" >
<!-- Stuff inside --->
</RelativeLayout>
</RelativeLayout>
Define a fixed size to your ScrollView. As bigger as the text becomes, the scroll is defined to that size (like layout_height="100dp")
UPDATE
Try something like this
<?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="200dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- TextView's inside - -->
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- CheckBox's inside - -->
</LinearLayout>
</LinearLayout>

How to scroll a view which is not in scrollview?

I designed a headerlayout(background is transparent) which is not in the scrollview and a scrollview which is in below of that header,in that scrollview have a layout with fixed height 1000dp and in the scrollview i added the views dynamically upto this its fine for me..But my problem is when i scroll the scrollview the background image also moving(background image height is 1550px) at the same time i want to change the background for the header as it is in scrollview background.....
i am not able to implement this please anyone help me in this designing..Below is my designing code..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/navbar"
android:background="#drawable/navbar_blooptransprant64"
/>
<ScrollView
android:layout_below="#+id/navbar"
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1000dp"
android:background="#drawable/new_bg"
android:orientation="vertical"
>
<LinearLayout
android:id="#+id/outer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>

How can I get a ScrollView with centered content and a footer?

i am trying to achieve the following in one of my layouts for my android app:
I would like to have a layout that holds the main content (linearlayout with other content) and a footer (linear layout with other content). The main content should be centered both horizontally and vertically. The footer should just be centered horizontally and always stay at the bottom.
In addition to that, the main content and the footer should be wrapped in a scrollview because it is possible that the main content grows and all the content should stil be accessible.
How can I do that?
I think the following gets close to what you want with the assumption that when you wrote 'The footer should just be centered horizontally and always stay at the bottom.' you meant the bottom of the screen.
<?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"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_above="#+id/footer" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:minLines="0"
android:visibility="invisible"/>
<TextView
android:id="#+id/body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My main body text to display"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:minLines="0"
android:visibility="invisible"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:id="#+id/footer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My footer text to display"/>
</LinearLayout>
Assuming this isn't quite right it should hopefully at least give you some ideas.

Android ListView. Vertical scrollbar isn't visible always for wide list

I have ListView which is wider than parent view. To have horizontal scrolling I've wrapped it with HorizontalScrollView.
Simplified layout XML:
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/main"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="#+id/children"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
</HorizontalScrollView>
So that I have vertical scrollbar in the ListView and horizontal scrollbar in the HorizontalScrollView.
My problem is that I don't see vertical list scrollbar unless the HorizontalScrollView isn't scrolled to the rightest position. Because vertical scrollbar along the right edge of the ListView.
Is there a way to make vertical scrollbar visible along the right edge of HorizontalScrollView?
To make list vertical scrollbar visible in any HorizontalScrollView position.
Try this instead:
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none">
<LinearLayout android:id="#+id/main"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ListView android:id="#+id/children"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</HorizontalScrollView>

Categories

Resources