Problem with webview and scrollview

I can not solve my problem with scrollView and webView, I know that I can not put webview in scrollview, but I do not know how to skip it. In my scrollView, I have an image (1280 x 1300>), and this image should scroll, under the image I should have a webview with html content. Do you know how to do this?

Is this any other way to put html content in some kind?

this is my xml view and i am adding image and webview to my activity class

<?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:id="@+id/mainLinear" android:orientation="vertical" > <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="match_parent" > <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="match_parent" > <ProgressBar android:id="@+id/progressBar1" style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" /> </RelativeLayout> <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="match_parent" > <ScrollView android:id="@+id/scroll_journal_page" android:layout_width="fill_parent" android:layout_height="fill_parent" > </ScrollView> <Gallery android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="#d5d5d3" /> </RelativeLayout> </RelativeLayout> </LinearLayout> 

I am creating a view something like this:

  protected void onPostExecute(Bitmap result) { Animation fadeInAnimation = AnimationUtils.loadAnimation(Journal.this, R.anim.fade_in); relativeLayout = new LinearLayout(getApplicationContext()); relativeLayout.setLayoutParams(new FrameLayout.LayoutParams(WIDTH, result.getHeight() + HEIGHT)); relativeLayout.setOrientation(1); coverImage = new ImageView(getApplicationContext()); coverImage.setImageBitmap(result); relativeLayout.addView(coverImage); Integer pageNumber = Integer.valueOf(ArrayHelper.journalList.get(pageIdentity).get("pageId").toString()); File file = new File(Environment.getExternalStorageDirectory() + "/MCW/"+ pageNumber +"/content.html"); if(file.exists()) { LinearLayout linearLayout = new LinearLayout(getApplicationContext()); linearLayout.setLayoutParams(new FrameLayout.LayoutParams(WIDTH, HEIGHT)); WebView wV = new WebView(getApplicationContext()); try { InputStream fin = null; int len; fin = new BufferedInputStream(new FileInputStream(file)); byte[] buffer = new byte[fin.available()]; len = fin.read(buffer); fin.close(); String rawText = EncodingUtils.getString(buffer, 0, len, "utf-8"); wV.loadDataWithBaseURL("", rawText, "text/html", "utf-8", null); }catch (Exception e) {} linearLayout.addView(wV); relativeLayout.addView(linearLayout); } scrollview.addView(relativeLayout); scrollview.setAnimation(fadeInAnimation); isReadyToChange = true; } 
+4
source share
3 answers

Just use Scrollview with Height FillParent add linearlayout height = deviceHeight + imageHeight

use line output with device height add web view to this linear line add image and linearlayout to this layout

0
source
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ScrollView android:layout_width="wrap_content" android:layout_height="fill_parent"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:id="@+id/pho" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/dd1"/> <WebView android:id="@+id/webView" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </ScrollView> </RelativeLayout> 
0
source

I'm not sure if this will fulfill your requirement or not, however

 is any another way to put html content with to some view ? 

You can use TextView to display HTML content.

mTextView.setText(Html.fromHtml('html_content'));

Also check out Marc Murphy - HTML tags supported by TextView

As a side note, HTML can also be used as a string resource, as described here.

0
source

Source: https://habr.com/ru/post/1392035/


All Articles