Autore Topic: adattare le img dentro la webview  (Letto 946 volte)

Offline japper

  • Nuovo arrivato
  • *
  • Post: 27
  • Respect: 0
    • Mostra profilo
adattare le img dentro la webview
« il: 27 Luglio 2012, 15:23:15 CEST »
0
Ciao a tutti ,
Io ho un pezzo di codice scritto in html , lo inserisco nella WebView e funziona tutto bene. Però le img  giustamente nn si adatta alla dimensione del display del cell. Quindi la mai domanda è come faccio a risolvere questo problema?

Ho gia visto qualche soluzione ma nn mi è per niente chiaro:
- mi creo un css
- i pattern

facciamo finta che io ho questa stringa nella webview :


Citazione
         <content:encoded><![CDATA[<img width="630" height="354" src="http://androidandme.com/wp-content/uploads/2012/07/pebble-smartwatch-hello.jpg" class="attachment-61082 wp-post-image" alt="pebble-smartwatch-hello" title="pebble-smartwatch-hello" /><p>With close to 70,000 backers and over $10 million raised, the <a href="A behind-the-scenes look at the creation of the HTC EVO 4G LTE |  Android and Me smartwatch is one of the most anticipated projects in <a href="http://www.kickstarter.com/">Kickstarter&#8217;s</a> history. The founders originally planned to send out orders for the device in September, but the demand was so overwhelming that they have now announced they won&#8217;t be able to start shipping on time.</p>
<p>Before they launched on Kickstarter, Pebble only planned to manufacture 1,000 units. Now they are going to produce an initial run of 85,000 units, so their timetable has shifted. Pebble says they are currently in a phase called Engineering Verification, where they have engineering samples and they are evaluating each individual component. No timeframe was provided for when the first Pebble smartwatches might ship.</p>
<p>This could be disappointing news if you were in the market for a new smartwatch, but there are alternatives. I&#8217;ve recently been wearing the <a href="Sony Smartwatch review |  Android and Me SmartWatch</a>, which can be found online for as low as <a href="Amazon.com: Sony MN2SW SmartWatch for Android Phones  - Retail Packaging - Black: Cell Phones & Accessories$114</a><img src="http://www.assoc-amazon.com/e/ir?t=andandme-20&amp;l=as2&amp;o=1&amp;a=B007VG6ZC8" alt="" width="1" height="1" border="0" />, and I continue to be impressed with the device. It&#8217;s hard to compare it to the Pebble since that hasn&#8217;t launched yet, but Sony already has the advantage of an active developer ecosystem that has created over 100 apps.</p>
<p>Hopefully Pebble will update their timetable soon and let us know when the first watches will ship, but I wouldn&#8217;t be surprised if they were delayed til next year.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/ToLMnEMkJRLRPUICG4aEynVdEJA/0/da"><img src="http://feedads.g.doubleclick.net/~a/ToLMnEMkJRLRPUICG4aEynVdEJA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ToLMnEMkJRLRPUICG4aEynVdEJA/1/da"><img src="http://feedads.g.doubleclick.net/~a/ToLMnEMkJRLRPUICG4aEynVdEJA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="Pebble smartwatch will not ship in September as planned |  Android and Me src="http://feeds.feedburner.com/~ff/androidandme?i=ZbaeV66BmsE:Mj9Im_NOF0A:D7DqB2pKExk" border="0"></img></a> <a href="FeedBurner FeedFlare :: Send an Email src="http://feeds.feedburner.com/~ff/androidandme?d=yIl2AUoC8zA" border="0"></img></a> <a href="Digg - Submit a link src="http://feeds.feedburner.com/~ff/androidandme?i=ZbaeV66BmsE:Mj9Im_NOF0A:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/androidandme?a=ZbaeV66BmsE:Mj9Im_NOF0A:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/androidandme?i=ZbaeV66BmsE:Mj9Im_NOF0A:gIN9vFwOqvQ" border="0"></img></a> <a href="Log In | Facebook src="http://feeds.feedburner.com/~ff/androidandme?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/androidandme?a=ZbaeV66BmsE:Mj9Im_NOF0A:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/androidandme?i=ZbaeV66BmsE:Mj9Im_NOF0A:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/androidandme/~4/ZbaeV66BmsE" height="1" width="1"/>]]></content:encoded>


sapete aiutarmi?

Offline bradipao

  • Moderatore globale
  • Utente storico
  • *****
  • Post: 4043
  • keep it simple
  • Respect: +567
    • Github
    • Google+
    • bradipao
    • Mostra profilo
  • Dispositivo Android:
    Nexus 5
  • Play Store ID:
    Bradipao
  • Sistema operativo:
    W7
Re:adattare le img dentro la webview
« Risposta #1 il: 27 Luglio 2012, 16:02:07 CEST »
0
Se ho ben capito il problema, dovresti poter trovare aiuto in questo:
Targeting Screens from Web Apps | Android Developers
NON rispondo a domande nei messaggi privati
Bradipao @ Play Store

Offline japper

  • Nuovo arrivato
  • *
  • Post: 27
  • Respect: 0
    • Mostra profilo
Re:adattare le img dentro la webview
« Risposta #2 il: 27 Luglio 2012, 17:15:38 CEST »
0
Codice (Java): [Seleziona]
String css = "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"img.css\">";
                String meta = "<meta name=\"viewport\" content=\"width=device-width\">";
                String s ="<html><head>" + meta + css + "</head><body>";
s += contentArticolo;
                s += "</body></html>";
myWebView.loadDataWithBaseURL(
                        "file:///android_assets", s , "text/html", "UTF-8", null);

l'ho messo ma nn va , che serve qualcos'altro oltre al tag meta?
« Ultima modifica: 27 Luglio 2012, 17:34:57 CEST da japper »

Offline japper

  • Nuovo arrivato
  • *
  • Post: 27
  • Respect: 0
    • Mostra profilo
Re:adattare le img dentro la webview
« Risposta #3 il: 30 Luglio 2012, 13:27:23 CEST »
0
alla fine con un semplice css ho risolto:

Codice: [Seleziona]
body{
       
}
.immagine img{
        width: 100%;
        height: auto;
}

Offline Giovanni D'Addabbo

  • Utente normale
  • ***
  • Post: 163
  • Respect: +8
    • Google+
    • giovannid
    • giovanni.daddabbo
    • magoscuro
    • Mostra profilo
    • Rhubbit.it - Sviluppo app Android/iOs
  • Dispositivo Android:
    Nexus 5
  • Play Store ID:
    Rhubbit srl
  • Sistema operativo:
    Windows/Mac/Linux
Re:adattare le img dentro la webview
« Risposta #4 il: 30 Luglio 2012, 15:03:34 CEST »
0
infatti il css per la sola immagine è una soluzione facile da implementare ed al contempo efficace

Offline japper

  • Nuovo arrivato
  • *
  • Post: 27
  • Respect: 0
    • Mostra profilo
Re:adattare le img dentro la webview
« Risposta #5 il: 30 Luglio 2012, 15:16:28 CEST »
0
lo so ma mi serviva adattare solo alcune img nn tutte , e quindi mi so dovuto fare il parse del codice e aggiungere l'img nel div del css... e quindi speravo che ci fosse qualcosa di più semplice tipo il tag meta nella head