Adding Scrollview in Android Project Layout - java

I'm trying to let me layout scroll down. I've seen some posts with this, and I tried to do what they explained, but it didn't work for me. This is what I have now, and now my project won't even start, probably cause it's missplaced.
This is how my code looks like:
<LinearLayout 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"
tools:context="com.example.rodekruis.Bezoek" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="20dp"
android:src="#drawable/rkz_logo" />
<ScrollView
android:id="#+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="#+id/textView1"
android:layout_width="244dp"
android:layout_height="276dp"
android:layout_gravity="center"
android:text="#string/title_activity_contact"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<TextView
android:id="#+id/textView2"
android:layout_width="244dp"
android:layout_height="42dp"
android:layout_gravity="center"
android:layout_weight="0.39"
android:text="Klik hier voor de uitgebreide contactgegevens."
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
</ScrollView>
</LinearLayout>

ScrollView can only has one child so you should add a Layout Manager that wrap all layout in ScrollView.
<LinearLayout 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"
tools:context="com.example.rodekruis.Bezoek" >
...
<ScrollView
android:id="#+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="#+id/textView1"
.../>
<TextView
android:id="#+id/textView2"
.../>
</LinearLayout>
</ScrollView>
...

Scrollview has a only one child and your layuot having two child, use this spinets
<LinearLayout 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">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="20dp" />
<ScrollView
android:id="#+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textView1"
android:layout_width="244dp"
android:layout_height="276dp"
android:layout_gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<TextView
android:id="#+id/textView2"
android:layout_width="244dp"
android:layout_height="42dp"
android:layout_gravity="center"
android:layout_weight="0.39"
android:text="Klik hier voor de uitgebreide contactgegevens."
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
</LinearLayout>
</ScrollView>

Related

Bottom Navigation View goes up with windowSoftInputMode=adjustResize

I need windowSoftInputMode= adjustRezise for my layout so that my buttons go up with the keyboard. BUT I don't want my BottomNagivationView to be affected by this.
How can I solve such?
My BottomNavigationView comes from MainActivity.xml which is:
<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"
tools:context=".MainActivity">
<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_navigation"></FrameLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
app:menu="#menu/bottom_menu"/>
</RelativeLayout>
My manifest has android:windowSoftInputMode="adjustPan" but I adjust it by code when I open the fragment with:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Here are some pictures so you could understand what I mean: https://imgur.com/a/vjePxI6
So what I would like to know is how I could set the BottomNavigationView to do nothing on keyboard opening while I'd like my buttons to be affected by :
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
In my case problem solved by just adding following line in manifest file.
android:windowSoftInputMode="adjustResize|adjustPan"
add android:windowSoftInputMode="adjustPan" inside your activity tag into your manifest file.
then go to your activity and change the parent layout to RelativeLayout, then create your FrameLayout which holds your fragments inside your relative layout which is your parent layout. Then add your second layout which is LinearLayout that holds the bottomNavigationView and make its Height and width match_parent but below the FrameLayout.
Below is the example of the main activity layout
<?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:orientation="vertical"
tools:context=".MainActivity">
//FrameLayout which holds all your fragments
<FrameLayout
android:id="#+id/fragments_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
//BottomNavigationView Container
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:layout_below="#id/fragments_container">
//BottomMenus
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="#+id/bottom_navigation"
android:background="#drawable/rectangle_4_dash"
android:layout_alignParentBottom="true">
//Container of Menus
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="5">
//BottomMenu One
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:src="#drawable/home_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Home" />
</LinearLayout>
//BottomMenu Two
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:src="#drawable/contact_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Contact" />
</LinearLayout>
//BottomMenu Three
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:src="#drawable/about_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About"
android:layout_gravity="center"/>
</LinearLayout>
//BottomMenu Four
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="17dp"
android:layout_gravity="center"
android:src="#drawable/services_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Services"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
</com.google.android.material.bottomnavigation.BottomNavigationView>
</LinearLayout>
Then go to your fragment which you want to scroll and design it like below one.
<?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="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Title Of Your Form"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/f_name"
android:inputType="textPersonName"
android:padding="10dp"
android:textSize="14sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="#string/m_name"
android:inputType="textPersonName"
android:padding="10dp"
android:textSize="14sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="#string/l_name"
android:inputType="textPersonName"
android:padding="10dp"
android:textSize="14sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Message"
android:inputType="text"
android:padding="10dp"
android:textSize="14sp" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="Send Messagge"
android:textAllCaps="false"
android:textColor="#color/white"
android:layout_marginBottom="40dp"/>
</LinearLayout>
</ScrollView>
That is how i solved it,
if you have any doubt please let me know but if its helps or looks like a correct answer please mark it as a correct answer thanks.

admob banner not showing in LinearLayout

hello AdMob banner ads not showing up any more after I add ScrollView I don't know why I tried many time but nothing
before added ScrollView is was working well
I have tried many methods to put in bottom the layout but not working with me
plz if you can help me I want to I want to place the ad on the bottom I have a LinearLayout. When I do it never shows up
<Toolbar
android:id="#+id/mytoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Toolbar>
<ScrollView
android:layout_above="#+id/adView"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:gravity="center_vertical"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip">
<TextView
android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Extreme power saving mode" />
</LinearLayout>
<Switch
android:id="#+id/setSwitch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10.0dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:gravity="bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/ad_banner">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</LinearLayout>
I looked into your code. Wrap your layout in relative. Layout below and above only works in relative not in linear, and remove the two linear layout below that is wrapping the adView.
This should work
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:orientation="vertical"
android:background="#fff1f1f1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto">
<Toolbar
android:id="#+id/mytoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</Toolbar>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/mytoolbar"
android:layout_above="#+id/adView">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:gravity="center_vertical"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip">
<TextView
android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Extreme power saving mode" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3.0dip"
android:text="The disadvantage is that the playback progress will be lost."
android:ems="11" />
</LinearLayout>
<Switch
android:id="#+id/setSwitch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10.0dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip">
<TextView android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Desktop control playback" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3.0dip"
android:text="Quickly click or swipe three times" />
</LinearLayout>
<Switch android:id="#+id/setSwitch2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10.0dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<TextView
android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip"
android:text="Sound" />
<Switch
android:id="#+id/setSwitch3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10.0dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/setRelativeLayout1"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip">
<TextView
android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Compatibility mode" />
<TextView
android:id="#+id/moreTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3.0dip"
android:text="MIUI8 set as lock screen wallpaper" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/setRelativeLayout2"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<TextView
android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip"
android:text="Get Starry Sky Wallpaper" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlRate"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<TextView android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip"
android:text="rate us " />
</RelativeLayout>
<RelativeLayout android:id="#+id/setRelativeLayout3"
android:background="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip">
<TextView android:textSize="17.0sp"
android:textColor="#ff000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15.0dip"
android:text="Close wallpaper" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/ad_banner">
</com.google.android.gms.ads.AdView>
</RelativeLayout>

Android Align LinearLayout at Bottom not Working

I have this LinearLayout and in it is a Map Fragment and this all works but I cannot get the linear layout to align to the bottom of the screen for some reason. Here is my xml:
<LinearLayout 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"
tools:context=".MainActivity"
android:baselineAligned="false"
android:weightSum="1"
android:background="#mipmap/background_colour">
<LinearLayout
android:orientation="vertical"
android:layout_width="30dp"
android:layout_height="31dp"
android:weightSum="1"
android:id="#+id/back_button"
android:background="#drawable/navigation_back"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp">
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.31">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/textView7" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.30">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/textView6" />
</LinearLayout>
<LinearLayout
android:id="#+id/lay"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:layout_weight="3.5">
</LinearLayout>
</LinearLayout>
The LinearLayout I am trying to align is the id: "lay" one.
I found a fix:
<LinearLayout 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"
tools:context=".MainActivity"
android:baselineAligned="false"
android:weightSum="1"
android:background="#mipmap/background_colour">
<LinearLayout
android:orientation="vertical"
android:layout_width="30dp"
android:layout_height="31dp"
android:weightSum="1"
android:id="#+id/back_button"
android:background="#drawable/navigation_back"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp">
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="177dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/textView7" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="146dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/textView6" />
</LinearLayout>
<LinearLayout
android:id="#+id/lay"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="match_parent">
</LinearLayout>
</LinearLayout>

Adding a normal Layout under a MapFragment

i'm trying to add a menu panel under a MapFragment but the thing always appear in the middle of the screen, like floating. I've tried several layout configurations but nothings seems to work.
This is my 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=".MapActivity" >
<fragment
android:id="#+id/panel_map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="vertical" />
<LinearLayout
android:id="#+id/newmarker"
android:layout_width="match_parent"
android:layout_height="85dp"
android:layout_gravity="center"
android:background="#FFFFFFFF"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="4dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Nuevo marcadort"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:id="#+id/newmarker_options"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:layout_gravity="center"
android:background="#FFFFFFFF"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/newmarker_save"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="#+id/newmarker_delete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
This is the actual result:
Any idea? What I'm doing wrong?
i just added android:layout_gravity="bottom" to newmarker 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=".MapActivity" >
<fragment
android:id="#+id/panel_map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="vertical" />
<LinearLayout
android:layout_gravity="bottom"
android:id="#+id/newmarker"
android:layout_width="match_parent"
android:layout_height="85dp"
android:background="#FFFFFFFF"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="4dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Nuevo marcadort"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:id="#+id/newmarker_options"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:layout_gravity="center"
android:background="#FFFFFFFF"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/newmarker_save"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="#+id/newmarker_delete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</FrameLayout>

How to scroll all contents of layout in Android?

My marking has some elements. These elements shall be scrolled completely, when scrolling down the calendar shall leave for screen limits if it it is necessary and to scroll LinearLayout contents.
I already tried to add ScrollView, it was ineffectual since all screen entirely but only a calendar, I ask to help was scrolled not.
Here Layout code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout_calendar"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="vertical" >
<RelativeLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/calendar_top" >
<RelativeLayout
android:id="#+id/previous"
android:layout_width="40dip"
android:layout_height="30dip"
android:layout_alignParentLeft="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/arrow_left" />
</RelativeLayout>
<TextView
android:id="#+id/title_calendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dip"
android:textColor="#000000"
android:textSize="18dip"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/next"
android:layout_width="40dip"
android:layout_height="30dip"
android:layout_alignParentRight="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/arrow_right" />
</RelativeLayout>
</RelativeLayout>
<GridView
android:id="#+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="#android:color/transparent"
android:numColumns="7"
android:stretchMode="columnWidth" >
</GridView>
<LinearLayout
android:id="#+id/linLayout_all_ivents_in_this_day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical" >
</LinearLayout>
</LinearLayout>
You can use scrollView.
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
-> your xml code <-
</ScrollView>
The only think you need to know is that scrollview only can have one child node, preferencialy a LinearLayout.
Use the ScrollView: http://developer.android.com/reference/android/widget/ScrollView.html
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/LinearLayout_calendar"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="vertical" >
<RelativeLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/calendar_top" >
<RelativeLayout
android:id="#+id/previous"
android:layout_width="40dip"
android:layout_height="30dip"
android:layout_alignParentLeft="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/arrow_left" />
</RelativeLayout>
<TextView
android:id="#+id/title_calendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dip"
android:textColor="#000000"
android:textSize="18dip"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/next"
android:layout_width="40dip"
android:layout_height="30dip"
android:layout_alignParentRight="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/arrow_right" />
</RelativeLayout>
</RelativeLayout>
<GridView
android:id="#+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="#android:color/transparent"
android:numColumns="7"
android:stretchMode="columnWidth" >
</GridView>
<LinearLayout
android:id="#+id/linLayout_all_ivents_in_this_day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>

Categories

Resources