scrollview a table under full scroll viewd intent (view) - android

<?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"
tools:context=".MainActivity">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:text="Mesaj Başlığı"
android:padding="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textExtendHeader"
android:layout_marginBottom="2dp"
android:textStyle="bold"
android:textSize="22sp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_x="0dp"
android:layout_y="0dp"
android:layout_gravity="center_horizontal|top">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="000dp">
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:gravity="top">
<ListView
android:id="#+id/ListC"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#FFDAFF7F" />
</ScrollView>
</TableRow>
</FrameLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
i got two scrollview elements;
first whole pages goes and up while scroll and second scrollview element is a tableview, when i try to scrollview table, doesnt sense only whole page scrolls.
is there a trick to scroll separate table view and page?

Related

ScrollView with LinearLayout child does not wrap_content correctly

So, I have the following .xml:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.scopesystems.cityalert.ui.Despre"
tools:showIn="#layout/app_bar_despre"
android:background="#drawable/toolbar_incercare">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/linear_parent">
<RelativeLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.1" />
<RelativeLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2.8" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--General-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/sectionHeader"
android:text="#string/general"
/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/despre_general"/>
<!--Evaluti-ne-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/sectionHeader"
android:text="#string/evaluatine"
/>
<!--Confidentialitate si licente-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/sectionHeader"
android:text="#string/confidentialitate"
/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/despre_politici"/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.1" />
</LinearLayout>
</ScrollView>
The issue is that the last ListView is on only 1 row, and it has to be scrolled to display all the items in the list. I tried to add to the linear_parent a height of match_parent but it wont let me, it says that I should use instead wrapcontent. How can i change the layout to display the items on all the screen, not just half?
In this case, On the ScrollView use android:fillViewport="true" and for child of ScrollView android:height="wrap_content".

View not filling the parent

I have an activity that contains a horizontal recycler view.
Now the main problem is I want to have a comment layout like the one in whats app which is at the bottom of the screen which is not filling the parent.
activity layout:
<?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.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_mood_detail_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
row view of the recycler view:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="#+id/row_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_large"
android:layout_marginRight="#dimen/margin_large"
>
<ImageView
android:id="#+id/quote_image_mood_detail_activity"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:scaleType="centerCrop"
/>
<include
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="#layout/layout_like_and_share"
android:layout_gravity="right"
/>
<com.ascentbrezie.brezie.custom.CustomTextView
android:id="#+id/comments_count_text_mood_detail_activity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size_small"
android:layout_margin="#dimen/margin_small"
/>
<LinearLayout
android:id="#+id/display_comments_layout_mood_detail_activity"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_margin="#dimen/margin_small"
/>
<include
android:id="#+id/abc"
layout="#layout/layout_add_comments"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
When I use the above two codes I have the output as this
But I want to set the edittext and the button at the button of the layout as the footer,for that when I am using this layout.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="#+id/row_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_large"
android:layout_marginRight="#dimen/margin_large"
>
<ImageView
android:id="#+id/quote_image_mood_detail_activity"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:scaleType="centerCrop"
/>
<include
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="#layout/layout_like_and_share"
android:layout_gravity="right"
/>
<com.ascentbrezie.brezie.custom.CustomTextView
android:id="#+id/comments_count_text_mood_detail_activity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size_small"
android:layout_margin="#dimen/margin_small"
/>
<LinearLayout
android:id="#+id/display_comments_layout_mood_detail_activity"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_margin="#dimen/margin_small"
/>
</LinearLayout>
</ScrollView>
<include
android:id="#+id/abc"
layout="#layout/layout_add_comments"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Now the problem is I get the XML preview exactly as I want. Have a look [here] but when I run the app on any device I get the output like this.
So the main problem is the footer layout doesn't stretch to fill up the parent and leaves some space to the right of the screen. I have dynamically set the margin for the whole of the view also.
RowLayout is the linear layout inside the scrollview. Card width is the width of the screen
rowLayout = (LinearLayout) holder.v.findViewById(R.id.row_layout);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(cardWidth, ViewGroup.LayoutParams.FILL_PARENT);
layoutParams.setMargins(10, 10, 0, 0);
rowLayout.setLayoutParams(layoutParams);
This should do it
<LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"><EditText android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1"/><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button"/></LinearLayout>

Adding a Button at the end of ListView

I want to add a button at the end of a list view. I have the following xml file. The list view appears with its contents, but the button does not show up.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/myListView" />
<Button
android:text="Project Download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/download" />
</LinearLayout>
The problem is with the attribute android:layout_height="match_parent" in your ListView. match_parent means that the listview will fill all the space. The correct way is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:weight="1"
android:id="#+id/myListView" />
<Button
android:text="Project Download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/download" />
</LinearLayout>
Your button is not shown because your ListView took the whole space hiding your button as you set its layout_height to match_parent. match_parent will take the whole available space. So change it to wrap_content like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_parent"
android:id="#+id/myListView" />
<Button
android:text="Project Download"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/download" />
</LinearLayout>
wrap_content will wrap your view to the least available height/width without hiding anything or making anything unclear.
i have the same problem, and solved.
you only need wrap that layout into ScrollView
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_transaction_history"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</android.support.v7.widget.RecyclerView>
<Button
android:id="#+id/btn_history_load_more"
style="?borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:paddingBottom="#dimen/margin_big"
android:paddingTop="#dimen/margin_large"
android:text="#string/text_btn_load_more"
android:textColor="#009CDE"
android:textSize="#dimen/text_size_medium" />
</LinearLayout>
</ScrollView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<Button
android:layout_alignParentBottom="true"
android:text="Project Download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/download" />
<ListView
android:layout_above="#id/download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/myListView" /></RelativeLayout>

ListView not scrollable

My ListView does not receive onScroll events in case it is short and does not fill the whole screen, which is strange, because I have set fill_parent as height.
My layout:
<?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:background="#drawable/bg_login_screen3"
android:orientation="vertical" >
<CheckBox
android:id="#+id/overview_allcars_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/all_cars"
android:textSize="14sp" />
<LinearLayout
android:id="#+id/list_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:cacheColorHint="#00000000"
android:fadingEdge="horizontal"
android:scrollingCache="true" />
</LinearLayout>
</LinearLayout>
You may find this answer useful:-
Making TextView scrollable on Android
Thats what helped me there:
<ScrollView
android:id="#+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
<TextView
android:id="#+id/TEXT_STATUS_ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"/>
</ScrollView>
Mainly you wrap your TextView in a ScrollView.

RelativeLayout, Include and layout_alignParentBottom doesn't work

How do I let my include exactly at the end of the screen? At the time he gets to the end of the content.
<!-- language: lang-xml -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#f6ba79"
android:orientation="vertical" android:id="#+id/layout">
<LinearLayout android:id="#+id/linearLayout2"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#drawable/preferences_background">
<include android:id="#+id/include1" android:layout_width="fill_parent"
layout="#layout/top" android:layout_height="wrap_content"></include>
<LinearLayout android:layout_width="fill_parent"
android:gravity="center" android:id="#+id/linearLayout1"
android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical"
android:layout_width="270dp" android:id="#+id/body"
android:layout_height="wrap_content" android:focusableInTouchMode="true">
<ImageView android:src="#drawable/preferences"
style="#style/Theme.Connector.ImageElement" android:layout_width="wrap_content"
android:id="#+id/title" android:layout_height="wrap_content"></ImageView>
<Spinner android:layout_width="fill_parent"
style="#style/Theme.Connector.WelcomeSpinner"
android:layout_weight="1" android:id="#+id/spinner_isp"
android:layout_height="wrap_content" />
<EditText android:singleLine="true" android:hint="#string/txt_user"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:id="#+id/edit_user" style="#style/Theme.Connector.PreferencesInput" />
<EditText android:singleLine="true" android:hint="#string/txt_password"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:id="#+id/edit_password" android:password="true"
style="#style/Theme.Connector.PreferencesInput" />
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:id="#+id/frm_action"
android:layout_height="fill_parent" android:baselineAligned="false">
<Button android:text="#string/btn_save"
android:layout_weight="0" android:layout_width="130dp"
android:layout_height="wrap_content" style="#style/Theme.Connector.Button"
android:layout_gravity="center" android:id="#+id/btn_save"></Button>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<include android:id="#+id/include1" android:layout_width="fill_parent"
layout="#layout/menu" android:layout_height="wrap_content" android:layout_alignParentBottom="true"></include>
</RelativeLayout>
The problem is that your ScrollerView has a layout_height="fill_parent". RelativeLayout will make that view fill the entire space.
A LinearLayout will work better in your case:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#f6ba79"
android:orientation="vertical"
android:id="#+id/layout">
...
</ScrollView>
<include
android:id="#+id/include1"
android:layout_width="fill_parent"
layout="#layout/menu"
android:layout_height="wrap_content" />
</LinearLayout>
The key here is to have the height of the ScrollerView set to 0dp and the weight set to 1 (or any number really). LinearLayout will then stretch the ScrollerView to fill the view and still make room for the #layout/menu at the bottom.

Categories

Resources