How to put two webview one after another with wrap content? - android

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>

Related

i want to add linear layout and webview and the screen must be fully scrollable

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width=""
android:layout_height=""/>
<WebView
android:layout_width=""
android:layout_height=""/>
</LinearLayout>
</ScrollView>
This like layout I want to achieve where full screen need to be scrollable
Any one suggest better ideas
<?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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:background="#dedede"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="30dp"
android:text="LinearLayout" />
</LinearLayout>
<WebView
android:id="#+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</WebView>
</LinearLayout>
</ScrollView>
</LinearLayout>

Android: Displaying images in Expandablelist View

I am trying to display high-resolution images inside the expandable list view. Although I was able to display the image but it is not covering the entire screen width. I have tried numerous combination of match_parent and wrap_content, but still doesn't get any success. I am using picasso library to load image from url and display it in expandable list view.
activity_main.xml
<?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"
tools:context="deev.com.company.albumsdetails.MainActivity">
<TabHost
android:id="#+id/tabsForDetailsandAlbums"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/albumsTab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/metallicSilver"
android:orientation="vertical">
<ExpandableListView
android:id="#+id/albumsList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:indicatorLeft="android:attr/expandableListPreferredItemIndicatorLeft"
android:divider="#color/blackBottom"
android:dividerHeight="2dp">
</ExpandableListView>
</LinearLayout>
<LinearLayout
android:id="#+id/postsTab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/metallicSilver"
android:orientation="vertical">
<ListView
android:id="#+id/tab2List"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#color/blackBottom"
android:dividerHeight="2px"
/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
album_header.xml
<?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:paddingLeft="8dp">
<TextView
android:id="#+id/albumHeader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="20dp"
android:paddingLeft="?android:attr/expandableListPreferredItemIndicatorLeft"
/>
</LinearLayout>
album_list.xml
<?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="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/albumContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"/>
<ImageView
android:id="#+id/albumContent2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp" />
</LinearLayout>

Overlay an element of view

I have this layout for a fragment:
<?xml version="1.0" encoding="utf-8"?>
<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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include layout="#layout/header" />
</FrameLayout>
<ListView
android:id="#+id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none" >
</ListView>
</LinearLayout>
</FrameLayout>
and this is header:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:id="#+id/box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone" />
</LinearLayout >
Now when button is pressed, "box" should be populated and become visible, and box overlay the rest of views (in my case listview). Now when i press button ox does not overlay listview, but take a portion of screen (and listview moves down).
How can i do? thanks
Just use a RelativeLayout instead of LinearLayout, and put the FrameLayout after the ListView in xml ( to place the header over the list):
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none" >
</ListView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include layout="#layout/header" />
</FrameLayout>
</RelativeLayout>

How to add TextView at the end of a WebView

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>

Scroll issue in android

In my application i have an activity which has the following layout
<?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:background="#color/white">
<WebView android:id="#+id/detail_title" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="2dp" android:textColor="#android:color/black"
android:background="#android:color/white" />
<WebView android:id="#+id/detail_subtitle" android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:padding="2dp" android:background="#android:color/white" />
<WebView android:id="#+id/wv3" android:orientation="vertical"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:background="#android:color/white" />
</LinearLayout>
wv3 has a lot of html text which appears properly but the problem is that i am getting scroll only in wv3 and the rest of the layout remains static which is quite irritating. i want that the whole of the layout has scroll and not only wv3.
Modifiy your layout like 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">
<LinearLayout android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<WebView android:layout_width="match_parent" android:layout_height="200dip"
android:id="#+id/wv1"/>
<WebView android:layout_width="match_parent" android:layout_height="200dip"
android:id="#+id/wv2"/>
<WebView android:layout_width="match_parent" android:layout_height="500dip"
android:id="#+id/wv3"/>
</LinearLayout>
</ScrollView>

Categories

Resources