I have a Xamarin Android Webview inside a Swiperefreshlayout (which i use it in order to reload the webview content) as shown below:
<?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">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtURL" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<Button
android:text="Go"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/btnGO"
android:layout_weight="2" />
<Button
android:text="Forward"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/btnForward"
android:layout_weight="1" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.webkit.WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/webView" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
The problem: I have some tables inside the webview Whenever I scroll the content of the table dawn fast, I cant scroll it back up .. when I do that the refresh icon appears from behind the toolbar and reload the page.
Any suggestion?
enter image description here
Related
<?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"
tools:context=".list1">
<ImageView
android:id="#+id/sinb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/left"
android:padding="10dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
/>
<ListView
android:layout_below="#id/sinb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/listView1"
android:layout_marginTop="30dp"
android:layout_centerHorizontal="true"
android:choiceMode="multipleChoice" />
<Button
android:id="#+id/btn1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/listView1"
android:text="submit"/>
</RelativeLayout>
i have put these in Relative Layout..I have tried using ScrollView but it doesnt work . What i want is that a Submit button should be shown below Listview and when the list grows and goes offscreen the activity becomes scrollable and button should be shown below the end of listview.
For the behaviour you want, it will be better if you used a RecyclerView instead of a ListView and let it be inside a NestedScrollView, then enable nestedScrolling attribute on the RecyclerView. This way, you RecyclerView will behave like a long list and all views below it will only be visible after the list has been exhausted.
Check the answers in this link to see how others implemented it.
So for this you have to put your List and button inside NestedScrollView, but the Nestedscrollview has supported only a single child so firstly you have to put your List and button inside a Layout and then put the layout inside the NestedScrollView, You may refer the below code:
<?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"
xmlns:tools="http://schemas.android.com/tools">
<ImageView
android:id="#+id/sinb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:padding="10dp"
android:src="#drawable/left" />
<android.support.v4.widget.NestedScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#id/sinb">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="30dp"
tools:listitem="#layout/item_view_note"
android:choiceMode="multipleChoice" />
<Button
android:id="#+id/btn1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/listView1"
android:text="submit" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
Add ScrollView/NestedScrollView as a parent layout and add views inside scroll view (ListView and Button )
Try This 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"
tools:context=".list1">
<ImageView
android:id="#+id/sinb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/left"
android:padding="10dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
/>
<android.support.v4.widget.NestedScrollView
android:id="#+id/navigation_nested"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_below="#+id/sinb"
android:overScrollMode="never">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="#dimen/margin_15">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/listView1"
android:layout_marginTop="30dp"
android:layout_centerHorizontal="true"
android:choiceMode="multipleChoice" />
<Button
android:id="#+id/btn1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="submit"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout >
Make the hight of listView as fixed and then put the button below it.
I have added a floating action button with recyclerview which is also scrolling along with the recyclerview my problem is that I have a bottom navigation in main activity so I'm trying to put my floating action button above bottom navigation which is in the main layout when my fragment is called but instead my fab is shown at the end of recyclerview and it is also scrolling along with the recyclerview how can I make it not scroll when the fragment is called in MainActivity.
Please any help would be appreciated
My XML
<android.support.v4.widget.NestedScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" >
<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.ct.listrtrial.fragments.FeedFragment">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="Feed"
android:paddingTop="10dp"
android:paddingLeft="15dp"
android:textSize="35sp"
android:textColor="#color/White"
android:layout_weight="1"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/feed_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:paddingTop="15dp">
</android.support.v7.widget.RecyclerView>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="#drawable/ic_search_black_24dp"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Use RelativeLayout as Root layout
And Use android:layout_alignParentBottom="true" and
android:layout_alignParentRight="true" to attach your FloatingActionButton at bottom of screen
SAMPLE CODE
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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.ct.listrtrial.fragments.FeedFragment">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingLeft="15dp"
android:paddingTop="10dp"
android:text="Feed"
android:textColor="#color/White"
android:textSize="35sp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/feed_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:paddingTop="15dp">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="5dp"
android:src="#drawable/ic_search_black_24dp" />
</RelativeLayout>
You Should put floating action button outside of nested scrollview..
I'm having trouble creating a simple menu of links in Xamarin. The desired layout is an image header, the list of links, and a button at the bottom to close the menu. I'm using a ListView to display the links.
My layout displays as desired in the Visual Studio Designer, but when run on the emulator or an actual Android device, the ListView takes up the entire screen and the header and footer aren't visible. I've tried everything I can think of, including several different layouts, and always get the same result.
My XAML is below. Help?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/linearLayout1">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/topLayout">
<Toolbar
android:minHeight="?android:attr/actionBarSize"
android:background="?android:attr/colorPrimary"
android:minWidth="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/toolbar1">
<ImageView
android:src="#drawable/logo1"
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="1.0dp"
android:layout_gravity="center" />
</Toolbar>
</LinearLayout>
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/android.r."
android:background="#ffffffff" />
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout2">
<Toolbar
android:minHeight="?android:attr/actionBarSize"
android:background="#ffff8902"
android:minWidth="25px"
android:layout_width="match_parent"
android:layout_height="35dp"
android:id="#+id/toolbar3"
android:layout_alignParentBottom="true"
android:layout_marginTop="0.0dp">
<Button
android:text="^"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/menuCloser"
android:layout_gravity="center"
android:layout_marginLeft="0.0dp"
android:layout_marginRight="0.0dp"
android:textSize="40dp"
android:background="?android:attr/selectableItemBackground"
android:ems="1"
android:onClick="OnCloseMenu"
android:shadowColor="#android:color/transparent"
android:textColor="#ffffffff" />
</Toolbar>
</LinearLayout>
</LinearLayout>
In your list if you have more items then you have to scroll to get to the bottom to see the footer. Visual studio designer will show you the sample list with less items so that you can see header and footer. If you want footer to be placed in a fixed i.e you don't want to scroll then use relative layout.
Just replace your listview tag by
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/android.r."
android:background="#ffffffff" />
1> Issue was in your android:layout_height="0dp" it should be 0dp if you are using weight.
2> My suggestion is to use RecyclerView of android as you will face many inconsistency in ListView
3> Your code need to be cleanup as i think you are new to android
So as suggestion i just removed some unused properties,
<?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:id="#+id/linearLayout1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/topLayout">
<Toolbar
android:background="?android:attr/colorPrimary"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:id="#+id/toolbar1">
<ImageView
android:src="#drawable/ic_back"
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</Toolbar>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/android.r."
android:background="#ffffffff" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout2">
<Toolbar
android:minHeight="?android:attr/actionBarSize"
android:background="#ffff8902"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/toolbar3"
>
<Button
android:text="^"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/menuCloser"
android:layout_gravity="center"
android:layout_marginLeft="0.0dp"
android:layout_marginRight="0.0dp"
android:textSize="40dp"
android:background="?android:attr/selectableItemBackground"
android:ems="1"
android:onClick="OnCloseMenu"
android:shadowColor="#android:color/transparent"
android:textColor="#ffffffff" />
</Toolbar>
</LinearLayout>
</LinearLayout>
The following should show a scrollview that takes up the entire screen except for a small portion large enough for a button at the bottom. When I run this the button/layout does not show up at all. Only the scrollview which takes up the entire screen with other views I have within the scrollview. Thoughts?
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.th3ramr0d.armybodyfatcalculator.MainActivity"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
/>
</LinearLayout>
</LinearLayout
This will do the job for you
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context="com.th3ramr0d.armybodyfatcalculator.MainActivity"
xmlns:tools="http://schemas.android.com/tools"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="#+id/myButton">
</ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
android:layout_alignParentBottom="true"
android:id="#+id/myButton" />
</RelativeLayout>
I have a fragment,in which I have a calendar, text view and a listview. All these views are inside the scroll view. I need two things in that layout.
I want to disable the scrolling of the list view.
How scroll to invoke scroll view when I swipe up, I want to hide calendar and text view. And on swipe down. It shows the whole layout.
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:animateLayoutChanges="true"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_below="#+id/rel"
android:id="#+id/scroll"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/compactcalendar_view_container"
android:layout_below="#+id/rel"
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="New Text"
android:textColor="#e1dcdc"
android:background="#011627"
android:id="#+id/date_picker_text_view"
android:textAlignment="center" />
<com.github.sundeepk.compactcalendarview.CompactCalendarView
android:id="#+id/cvCalendar"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="250dp"
app:compactCalendarTargetHeight="250dp"
android:layout_below="#+id/textView14"
app:compactCalendarBackgroundColor="#011627"
app:compactCalendarCurrentDayBackgroundColor="#FFC107"
app:compactCalendarCurrentSelectedDayBackgroundColor="#939393"
app:compactCalendarTextColor="#e1dcdc"
app:compactCalendarTextSize="12sp" />
</LinearLayout>
<ListView
android:id="#+id/lvList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#e9e9e9"
android:dividerHeight="10dp"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:scrollbars="none"
android:background="#eee"
android:layout_below="#+id/scroll"
android:layout_centerHorizontal="true" />
</LinearLayout>
</ScrollView>
</RelativeLayout>