NightWhistler / HtmlSpanner

Android HTML rendering library with CSS support
http://nightwhistler.github.io/HtmlSpanner/
868 stars 209 forks source link

want to load css style tag on href link can you please tell what i need to write #44

Open jordan9827 opened 8 years ago

jordan9827 commented 8 years ago

private String getMessage(String message) { String messagestr = ""; if (other_user_id.equals("0")) {

        String str_css = "<style> @font-face {  font-family: MyFont; src: url(\"file:///android_asset/font/VAG-ROUNDED-STD-LIGHT.TTF\")  }"
                + ".btn-primary {color: #fff; background-color: #643C7B; border: 0 solid transparent; display: inline-block;"
                + " margin-bottom: 0; font-weight: normal; text-align: center; vertical-align: middle; cursor: pointer;border: 0 "
                + "solid transparent; white-space: nowrap; font-family: MyFont; padding: 4px 10px; "
                + "font-size: 13px; line-height: 16px; border-radius: 4px;text-decoration: none;} "
                + ".btn-sec {color: #fff; background-color: #D48000; border: 0 solid transparent; display: inline-block;"
                + " margin-bottom: 0; font-weight: normal; text-align: center; vertical-align: middle; cursor: pointer;border: 0 "
                + "solid transparent; white-space: nowrap; font-family: MyFont; padding: 4px 10px; "
                + "font-size: 13px; line-height: 16px; border-radius: 4px;text-decoration: none;}"
                + "a{color:#914DB8} body{font-family:MyFont !important;color:#4A4A4A} </style>";
        String subStringfirst = "<html><head>";
        String subStringlast = "</head></html>";
        System.out.println("log  " + message.substring(0, 6));
        if (message.substring(0, 6).equals("<html>")) {
            String messagestring = message.substring(12);
            messagestr = subStringfirst + str_css + messagestring;
        } else {
            String messagestring = message;
            messagestr = subStringfirst + str_css + messagestring + subStringlast;
        }
        System.out.println("message  " + subStringfirst + str_css + str_message);

    } else {
        messagestr = message;
    }
    return messagestr;
}
ghost commented 8 years ago

https://gist.github.com/NightWhistler/6e27af3f8b822a5ae734 You could see this and when you get the css string, the next steps are the same with StyledNodeHandler.

monowar1993 commented 7 years ago

Title

Sub Text 2nd Line

I want to format the above HTML text into android textView. Please help me to figure it out how can i do that. Your help will be much appreciated.