How to next child tablelayout android - android

I have a TableLayout within a ScrollView.
I need to go to the next LinearLayout (dynamically created) which is within the TableView clicking a close button and return to the previous LinearLayout by clicking the back button.
Follow my XML as I am creating the TableView:
<?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"
android:layout_weight="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:id="#+id/myLayout"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.v7.widget.Toolbar
android:id="#+id/tb_pergunta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<ScrollView
android:id="#+id/sv_table"
android:layout_height="match_parent"
android:scrollbars="horizontal|vertical"
android:layout_width="match_parent"
android:layout_marginTop="5dip"
android:scrollbarStyle="outsideInset"
android:fillViewport="true">
<TableLayout
android:id="#+id/tl_principal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="14">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ir para pergunta nÂș:"
android:id="#+id/btnProximaPergunta"
android:visibility="gone" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/botton_back"
android:id="#+id/btnBackGroupExpandable" />
<EditText
android:layout_width="99dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/edtProximaPergunta"
android:textAlignment="center" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/botton_next"
android:id="#+id/btnNextGroupExpandable" />
</LinearLayout>
</LinearLayout>
How can I do this?

You can give each LinearLayout a randomly generated ID as described here.
Store those IDs in an array and then you can easily call any of them in any order.

Related

FrameLayout after ScrollView allways on bottom

I need to made layout that will contain ScrollView with some dynamic length text and Button in FrameLayout after(below). With long text all is okay, but when text is short button stuck right below bottom of ScrollView text part. I want a FrameLayout in the bottom of the screen when text is short and right below ScrollView text part when text long .
Can it be done?
My XML
<android.support.constraint.ConstraintLayout 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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".TeacherFullActivity"
tools:showIn="#layout/app_bar_teacher_full">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
layout="#layout/listview_element_teachers"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/job_title"
style="#style/TitleMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/teacher_job_title" />
<android.support.v7.widget.RecyclerView
android:id="#+id/job_dynamic"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/subject_title"
style="#style/TitleMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/teacher_subject_title" />
<android.support.v7.widget.RecyclerView
android:id="#+id/subject_dynamic"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/workPlace_title"
style="#style/TitleMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/teacher_workplace_title" />
<android.support.v7.widget.RecyclerView
android:id="#+id/workplace_dynamic"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingLeft="35dp"
android:paddingTop="5dp"
android:paddingRight="35dp"
android:paddingBottom="5dp">
<Button
android:id="#+id/teacher_external_link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_rounded"
android:text="#string/open_link"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="17sp"
android:textStyle="bold"
/>
</FrameLayout>
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
You can use the android:fillViewport attribute of ScrollView to accomplish this.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<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"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"/>
</FrameLayout>
</LinearLayout>
</ScrollView>
What this does is make it so that, in the case where the contents of the LinearLayout are not large enough to fill the screen, the LinearLayout is stretched to fill the screen anyway. That gives the FrameLayout room to grow (based on its layout_weight attribute), which in turn lets the Button float to the bottom of the screen (because of its layout_gravity attribute).
In cases where the contents of the LinearLayout are larger than the screen, no stretching happens. The button is pushed off-screen, but appears when you scroll down (with no space between it and the text).
You can try this code for your approach:
<android.support.constraint.ConstraintLayout 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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".TeacherFullActivity"
tools:showIn="#layout/app_bar_teacher_full">
<ScrollView
android:id="#+id/scrollview"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraintTop_toTopOf="parent"
app:constraintStart_toStartOf="parent"
app:constraintEnd_toEndOf="parent"
app:constraintBottom_toTopOf="#id/frame">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
layout="#layout/listview_element_teachers"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/job_title"
style="#style/TitleMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/teacher_job_title" />
<android.support.v7.widget.RecyclerView
android:id="#+id/job_dynamic"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/subject_title"
style="#style/TitleMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/teacher_subject_title" />
<android.support.v7.widget.RecyclerView
android:id="#+id/subject_dynamic"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/workPlace_title"
style="#style/TitleMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/teacher_workplace_title" />
<android.support.v7.widget.RecyclerView
android:id="#+id/workplace_dynamic"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<FrameLayout
android:id="#+id/frame"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingLeft="35dp"
android:paddingTop="5dp"
android:paddingRight="35dp"
android:paddingBottom="5dp"
app:constraintTop_toBottomOf="#id/scrollview"
app:constraintStart_toStartOf="parent"
app:constraintEnd_toEndOf="parent"
app:constraintBottom_toBottomOf="parent">
<Button
android:id="#+id/teacher_external_link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_rounded"
android:text="#string/open_link"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="17sp"
android:textStyle="bold"
/>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
Explaination:
What i did was took FrameLayout containing Button out side of ScrollView so that it can always be at bottom of the Container.

Some views don't show in RelativeLayout

I have the following RelativeView. I want
EditText at bottom
TextView on top - I have an issue here - it doesn't show but I don't understand why
2 ListViews between them - both taking half of the screen vertically
Please do you see why that top TextView doesn't show ?
<?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">
<EditText
android:id="#+id/Search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:layout_alignParentBottom="true">
<requestFocus />
</EditText>
<View android:id="#+id/Placeholder"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_above="#id/Search"
android:layout_centerInParent="true"/>
<ListView
android:id="#+id/ResultsColumn1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignRight="#id/Placeholder"
android:layout_above="#id/Search" />
<ListView
android:id="#+id/ResultsColumn2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignLeft="#id/Placeholder"
android:layout_above="#id/Search"/>
<TextView
android:id="#+id/InformationTextTop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/ResultsColumn1"
android:text="Why is this not visible ?"/>
</RelativeLayout>
It's simply because the ListViews have match_parent in the android:layout_height property and the TextView is defined after them in the xml. Since this is a pretty simple layout I would recommend to use the LinearLayout instead.
<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">
<TextView
android:id="#+id/InformationTextTop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/ResultsColumn1"
android:text="Why is this not visible ?"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<ListView
android:id="#+id/ResultsColumn1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<ListView
android:id="#+id/ResultsColumn2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<EditText
android:id="#+id/Search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text">
<requestFocus />
</EditText>
</LinearLayout>

How do you position views and other UI items in a fragment layout?

I have a message interface consisting of a listview, an edit text box and a button found in a tutorial online. In my implementation of the xml it lays out perfectly with the listview above the text box and button. However, when I try to implement the layout using two fragments (1) for an audio player at the top of the screen and (2) below that for the messaging, I cannot force the text box and button to display below the list view.
How can I do that below are the XMLs.
(1) Works as expected:
<?xml version="1.0" encoding="utf-8"?>
<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"
>
<ListView
android:id ="#+id/message_list"
android:layout_weight="100"
android:layout_width="match_parent"
android:layout_height="0dp"
android:divider="#null"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/new_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="100"
android:inputType="text">
<requestFocus />
</EditText>
<Button
android:id="#+id/send_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:text="#string/send_message"
android:textColor="#android:color/white" />
</LinearLayout>
</LinearLayout>
(2) Positions the text and button at the top of or near the top of the list view:
<?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:orientation="vertical">
<ListView
android:id="#+id/message_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#null" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/new_message"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="100"
android:inputType="text"
android:labelFor="#id/new_message" />
<Button
android:id="#+id/send_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:text="#string/send_message"
android:textColor="#android:color/white" />
</LinearLayout>
</RelativeLayout>
Changing (2) to linear layout has not fixed my issue.
This somehow fixed my problem although it seemed not to have worked before.
<?xml version="1.0" encoding="utf-8"?>
<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.app.MessageFragment">
<ListView
android:id ="#+id/message_list"
android:layout_weight="100"
android:layout_width="match_parent"
android:layout_height="0dp"
android:divider="#null"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/new_message"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="100"
android:inputType="text"
android:labelFor="#id/new_message" />
<Button
android:id="#+id/send_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:text="#string/send_message"
android:textColor="#android:color/white" />
</LinearLayout>
</LinearLayout>
Your second layout has no constraints. You should make sure that your LinearLayout is aligned bottom and the listview is above the LinearLayout. It should be something like this :
<?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:orientation="vertical">
<ListView
android:id="#+id/message_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/llText"
android:divider="#null" />
<LinearLayout
android:id="#+id/llText"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content">
<EditText
android:id="#+id/new_message"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="100"
android:inputType="text"
android:labelFor="#id/new_message" />
<Button
android:id="#+id/send_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:text="Hello"
android:textColor="#android:color/white" />
</LinearLayout>
</RelativeLayout>

Linear Layout with Weights and Scroll View

I'm trying to create a responsive layout using weights but I also need to use a scroll view in this case.
This is my code at this moment:
<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"
tools:context=".EncyclopediaFragment">
<!--Linear Container-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<!--Title Box-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="20"
android:orientation="horizontal"
android:weightSum="100">
<!--Empty Space-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="5">
</LinearLayout>
<!--Text Box-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="95">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/encyclopedia_mosntersLabel"
android:gravity="center"
android:textAlignment="viewStart"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="40">
</LinearLayout>
</LinearLayout>
but it needs to be like this.
That layout is suppose to be responsive with weights but at the same time I need to make it possible to scroll.
So my question is: how can I create a layout responsive with weights and at the same time a layout that can scroll down, just like in the picture?
If you have a determined number of 6 Monsters and 8 Towers, here is how you should organize your layout:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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:text="Monsters"/>
<!-- the following LinearLayout should be repeated twice for 6 Monsters -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<MonsterView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<MonsterView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<MonsterView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
...
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Towers"/>
<!-- the following LinearLayout should be repeated twice for 6 Towers -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TowerView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<TowerView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<TowerView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
...
<!-- attention here for two Towers in the last row -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<TowerView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<TowerView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>
The content inside your ScrollView should use wrap_parent, and if you want to stretch the content inside it set android:fillViewport="true". Try this:
<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"
tools:context=".EncyclopediaFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--Linear Container-->
</RelativeLayout>
</ScrollLayout>
</RelativeLayout>
<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"
tools:context=".EncyclopediaFragment">
<!--Toolbar-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--Linear Container With Weights-->
</RelativeLayout>
</ScrollLayout>
</RelativeLayout>

Button to bottom of screen

I have a layout that looks like this,
<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="match_parent"
android:orientation="vertical">
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="#layout/layout1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
I want the button to appear at the bottom of the screen which works fine if use it with an activity.When i try to use it with a fragment though (inside a FrameLayout) the button doesn't show at all.Any suggestions?
EDIT
Thanks for your answers but i've already tried all that.Let me clarify something.I have a main layout that contains a Toolbar and a Framelayout.This FrameLayout is used for my 4-5 app's Fragments.One of them has that previous layout i posted.
Use layout_weight
<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"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="#layout/layout1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button" />
</LinearLayout>
try to use:
android:layout_gravity="bottom"
or:
android:layout_alignParentBottom="true"
in the botton tag.
You should use ScrollView as a root layout than LinearLayout here.
And try this property inside scrollview :
android:fillViewport="true"
May be it will help you.
You need set property for ScrollView
android:fillViewport="true"
and the add below line to your button
android:layout_alignParentBottom="true"
android:layout_gravity="center_horizontal"
I have Edited your code just try this
<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:fillViewport="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="#layout/layout1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="button"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</ScrollView>
tasgr86 try to this code hope this can do some idea or help..
<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="wrap_content"
android:layout_above="#+id/button">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
layout="#layout/layout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Test" />
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:text="button" />
</RelativeLayout>

Categories

Resources