In my application I need to open a WebView that contains a long html file.
I would like to add a TextView at the end of the WebView, so that only when the user has finished scrolling the WebView, the TextView would show.
I have tried with this Layout, but, no surprise, when I have finished scrolling the WebView the TextView does not show
<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" >
<WebView
android:id="#+id/webView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
you should add a ScrollView which contains your LinearLayout. In you code :
<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="match_parent"
android:orientation="vertical" >
<WebView
android:id="#+id/webView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</ScrollView>
Related
I implement Webview in my app in Fragment but in Webview EditText Field Hide when the keyboard appears.
I Set
WindowSoftInputMode = SoftInput.StateHidden | SoftInput.AdjustResize
and android:fitsSystemWindows="true"
but not working for me.
I also use custom RelativeLayout but it's not working.
Please help me to solve this issue.
My Code is below in Fragment
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:orientation="vertical"
android:fillViewport="true">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
some layout and label
<RelativeLayout
android:id="#+id/reletivePurchaseWebview"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:visibility="gone"
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.webkit.WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_above="#+id/lblBuyMore"
android:id="#+id/webView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="25dp"
android:layout_centerHorizontal="true"
android:id="#+id/lblBuyMore"
android:layout_alignParentBottom="true"
app:fontFamily="#font/lato_medium"
android:gravity="center_vertical"
android:text="abc"
android:textColor="#24E5BA"
android:textSize="#dimen/textSize_11" />
</RelativeLayout>
</RelativeLayout>
</ScrollView >
While I was trying to replicate your problem the first thing android studio complained was
I would suggest you to update your layout as following and try again.
<?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"
android:layout_width="match_parent" // <-- Added this
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical"
android:scrollbars="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" // <-- Updated this
android:orientation="vertical">
//some layout and label
<RelativeLayout
android:id="#+id/reletivePurchaseWebview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:visibility="gone">
<android.webkit.WebView
android:id="#+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/lblBuyMore"
android:scrollbars="vertical" />
<TextView
android:id="#+id/lblBuyMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:padding="25dp"
android:text="abc"
android:textColor="#24E5BA"
android:textSize="#dimen/textSize_11"
app:fontFamily="#font/lato_medium" />
</RelativeLayout>
</RelativeLayout>
Manifest:
android:windowSoftInputMode="adjustPan" >
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
i have a Textview for displaying the contents of a file set to have both scrollbars, horizontal and vertical. it's working almost fine (scrolling both ways), but scrollbars aren't showing. bellow is my layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="com.example.luis.autorecreation_1.ShowXMLNotesFile">
<TextView
android:id="#+id/tvFileName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="notes.xml"
android:textAllCaps="true"
android:textColor="#android:color/black"
android:textSize="24sp"
android:textStyle="bold" />
<Button
android:id="#+id/btnBack_ShowXMLNotesFile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/back_button_text" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbarThumbHorizontal="#drawable/h_scrollbar_style"
android:scrollbarThumbVertical="#drawable/v_scrollbar_style"
tools:scrollbarThumbHorizontal="#drawable/h_scrollbar_style">
<TextView
android:id="#+id/tvXML"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="true"
android:scrollHorizontally="true"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarFadeDuration="0"
android:scrollbarThumbHorizontal="#drawable/h_scrollbar_style"
android:scrollbarThumbVertical="#drawable/v_scrollbar_style"
android:scrollbars="horizontal|vertical"
android:text="tvXMLFile" />
</HorizontalScrollView>
</ScrollView>
android:fadeScrollbars= "false"
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>
I want to put top WebView for article and another for load disque comment, I tried following code but not working.
Article WebView hide if Disque WebView load before article.
<RelativeLayout
android:id="#+id/layout_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#BDBDBD"
tools:context="com.examkida.article.ArticleViewActivity" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/txtArticle"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/disqus"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
The height of your second webview is fill_parent which would cause it to cover the first one, change it to wrap_content
I did this ........ like this way
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<WebView
android:id="#+id/txtArticle"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="wrap_content" />
<WebView
android:id="#+id/disqus"
android:layout_width="match_parent"
android:layout_below="#+id/txtArticle"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
</ScrollView>