Code Monkey home page Code Monkey logo

htmlview2's Introduction

htmlview2's People

Contributors

stefanhaustein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

htmlview2's Issues

using justify for text aligment

this library can be support text-align:justify;? we have 2 direction LTR and RTL, RTL is for such as arabic language or china

Stackoverflow getUnit/get

Here is my code:

String html = String.format("<html><head><style type=\"text/css\">%s</style></head><body>%s</body></html>", css, block.getData());
            try {
                Reader reader = new StringReader(html);
                htmlProcessor.parse(reader, uiHtmlView);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
  java.lang.StackOverflowError
            at org.kobjects.css.CssStyleDeclaration.getUnit(CssStyleDeclaration.java:333)
            at org.kobjects.css.CssStyleDeclaration.get(CssStyleDeclaration.java:165)
            at org.kobjects.css.CssStyleDeclaration.get(CssStyleDeclaration.java:102)
            at org.kobjects.css.CssStyleDeclaration.get(CssStyleDeclaration.java:217)
            at org.kobjects.css.CssStyleDeclaration.get(CssStyleDeclaration.java:102)
            at org.kobjects.css.CssStyleDeclaration.get(CssStyleDeclaration.java:217)
            at org.kobjects.css.CssStyleDeclaration.get(CssStyleDeclaration.java:102)
            at org.kobjects.css.CssStyleDeclaration.get(CssStyleDeclaration.java:217)

Parse from a HTML string instead of reader

I'm wondering is this possible? I have tried

processor.parse(BufferedReader(ByteArrayInputStream("abc".toByteArray(Charset.defaultCharset())).reader(Charset.defaultCharset())), htmlView) // Also tried using UTF-8

but it throws a runtime exception:

E/AndroidRuntime(24645): Caused by: org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT abc@1:4 in java.io.BufferedReader@2573efd)

Thanks in advance. This is an awesome library!

org.kobjects.css.CssStyleDeclaration.isSet()' on a null object reference

this is my html:

<html>
<head>
    <title>HtmlView Demo</title>
</head>
<body>
<p style="text-align:left;direction:ltr;background-color: #ddf;">
    <strong>
         Simple HTML to Native
        <p> Native Components </p>
         Engine for Android
    </strong>
</p>
</body>
</html>

Error:

Attempt to invoke virtual method 'boolean org.kobjects.css.CssStyleDeclaration.isSet(org.kobjects.css.CssProperty)' on a null object reference

Access directly to web

can i access directly to link on web? for example http://mysite.com/help.html to show and parse that without attaching to application or using HttpConnection

read html from string

is any solution to read and parse html tags from string? i have some html tags which i saved into database and i must read them from that, thanks

height css attribute not working?

hey stefan,

i am trying to set an explicit height using height attribute but there is no effect of it on the element, can you tell me about it?
<div style="background-color:yellow;height:100px;">element</div>

thanks,
Aweosome work btw,

Style HtmlView

I can't find how to properly style the HtmlView. It uses the CssStyleSheet, but I can't change anything about CssStyleSheet.
Also I can't find out how to set the font size.

Help/Wiki + release on Android Arsenal

This is the lightweight webview I've been looking for a long time. I have had a few apps where I load local html (nothing fancy, only bold, italic, ul, ol). But there wasn't a library that could do it all except WebView which is unbelievably slow. So first, thank you!

I've just been using the library, but there is not much explanation. For example I'm trying to set the base text size. But no clue how to do this. Also I find the indentation for ol and ul lists too big. Is there a way to make that smaller?

Like I said, I've been looking for this a long time. So maybe put it on Android Arsenal or other websites where people can find it and be as excited as me.

Click handlers, on clickable elements

hey stefanhaustein,

first of all, you did a great job by creating this and i am currently using it in a project of mine.
back to the issue, can i set a click listener to clickable elements like buttons, or get input from edittext views?

if there is any option like that, i am enable to find one.

thank you

make a clickable text

this code is simple way to make clickable part of string:

SpannableString ss = new SpannableString("Android is a Software stack");
ClickableSpan clickableSpan = new ClickableSpan() {
    @Override
    public void onClick(View textView) {
        startActivity(new Intent(MyActivity.this, NextActivity.class));
    }
    @Override
    public void updateDrawState(TextPaint ds) {
            super.updateDrawState(ds);
            ds.setUnderlineText(false);
        }
};
ss.setSpan(clickableSpan, 22, 27, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

TextView textView = (TextView) findViewById(R.id.hello);
textView.setText(ss);
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setHighlightColor(Color.TRANSPARENT);

now how can i implementing this feature for this library?

change background color inside <span>

when i trying to use background-color:#eee; for <span> such as :

<span>
    It's to
    <span style="color:#00ff00;background-color:#eee;">do do do do</span> so
</span>

background-color:#eee; dont apply for this part of text, that work only on <p> tag, for example this html work fine

<span>
    It's to
    <p style="color:#00ff00;background-color:#eee;">do do do do</p> so
</span>

show image from real path

You suppose i have some image into SDcard and i would like to show them on html, in sample of library image is into assets, but maybe i use and select image from other path, how can i do this action

change nested tag color

in this html:

<p style="color:green">
    salam
    <span style="color:red !important">
        simple text
    </span>
</p>

close and open parent tags don't resolve my problem any time because it can't be extends some propertise such as color,font face or other things from parent.
for example:

<p style="color:green">
    salam
    </p>
        <span>
            simple text
        </span>
    <p>
</p>

how can i change nested tag as : span

No output when calling multiple times

I am using the HtmlView inside a ScrollView which is part of an activity called by a button inside my main activity. The text inside the code snippet is shorter than the original one.

The first time I open the activity, everything is displayed as expected. After pressing back and opening it again, no text is visible any more.

public class MyHtmlActivity extends AppCompatActivity {
    private static final String myHtml = "<html><body><b>My Text</b></body></html>";
    private static final StringReader htmlReader = new StringReader(myHtml);
    private HtmlProcessor htmlProcessor = new HtmlProcessor();
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);
        ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView);
        HtmlView htmlView = new HtmlView(this);
        htmlProcessor.parse(htmlReader, htmlView);
        scrollView.addView(htmlView);
    }
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="myPackage.myActivity">

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent" >
    </ScrollView>
</android.support.constraint.ConstraintLayout>

org.xmlpull.v1.XmlPullParserException without outer tag such as <html>

@stefanhaustein hi, could you check this html code?

I'm using latest version of your library on Gradle
text = "hello world <br/> <p style='text-align:left;'>this is an code</p> <br/> end of text <br/> and <p style='text-align:left;'>this my code</p> <br/> finish";

I get this error:

java.lang.RuntimeException: Unable to start activity ---: java.lang.RuntimeException: java.lang.RuntimeException: org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT hello world @1:13 in java.io.StringReader@36a75a9)

My code:

try {
        text = "hello world <br/> <p style='text-align:left;'>this is an code</p> <br/> end of text <br/> and <p style='text-align:left;'>this my code</p> <br/> finish";
    
        Reader reader = new StringReader(text);
    
        HtmlView htmlView = new HtmlView(context);
        htmlProcessor.parse(reader, htmlView);
    
        ScrollView scrollView = new ScrollView(context);
        scrollView.addView(htmlView);
        markdownViewContent.addView(scrollView);
    } catch (Exception e) {
        e.printStackTrace();
        Log.e("HtmlView ", e.getMessage());
        throw new RuntimeException(e);
    }

library return null object reference error

for this html code:

text = "<p style='font-size:15px;text-align:right'><br/><h2 style='text-align:right'>hello world</h2><br/></p>";
or

text = "<p style='font-size:15px;text-align:right'><br></br><h2 style='text-align:right'>hello world</h2><br></br></p>";

i get this error:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.kobjects.css.CssStyleDeclaration.isSet(org.kobjects.css.CssProperty)' on a null object reference

my code:

    private void showContentPreviewAsHtml() {
        try {
            text = "<p style='font-size:15px;text-align:right'><br></br><h2 style='text-align:right'>hello world</h2><br></br></p>";
            Log.e("text ", text);
            Reader reader = new StringReader(text);

            HtmlView htmlView = new HtmlView(context);
            htmlProcessor.parse(reader, htmlView);

            ScrollView scrollView = new ScrollView(context);
            scrollView.addView(htmlView);
            markdownViewContent.addView(scrollView);

        } catch (Exception e) {
            e.printStackTrace();
            Log.e("HtmlView ", e.getMessage());
            throw new RuntimeException(e);
        }
    }

problem is break line <br/>, <br></br>, how can i use break line on start or end of html tags?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.