ورود

View Full Version : نمایش gif در webview مانند تبلیغات عدد



haniiii
دوشنبه 22 دی 1393, 09:10 صبح
سلام

به نظرتون چطوری پیاده سازی شده سیستم تبلیغات عدد ؟ ..

فقط بخش نمایش تبلیغ ... فرض کنید یک فایل gif دارم و میخوام نمایش بدم ... بهترین راه چی هست ؟

ممنون میشم راهنمایی کنید

Ebrahimkh
دوشنبه 22 دی 1393, 09:44 صبح
سلام دوست عزیز
شما باید با استفاده از سورس xml براش انیمیشن طراحی کنید

big lost
دوشنبه 22 دی 1393, 10:26 صبح
از این روش هم میتونی استفاده کنی :

فایل html :

<html><head><script src="banners.js"><style>html { position: relative; min-width: 320px; min-height: 50px; height: 100%;}</style></script></head><body style='margin:0;padding:0;' onLoad = "javascript:rotateBanner();javascript:setInterval(' rotateBanner()',20000);"><a href= "http://www.bigfoot.com/~java4free" onMouseOver = "javascript:pause()" onMouseOut = "javascript:resume()"><img style="margin-left:auto;margin-right:auto" src = "first1.jpg"></a></body></html>

کد جاوا اسکریپت :
<!-- //Hide from non-javascript browsers

//Author: Mark Ganson
//Date: 3/10/2000
//Site: http://www.bigfoot.com/~java4free


var nCurrentBanner = 0;
var bPause = false;


//replace these links with the appropriate href portion of your banner code
//example: <a href="java4free.html"><img src="java4freebanner.jpg></a>
//in the above example, "java4free.html" is the link string
//and "java4freebanner.jpg" is the image string


//href parts
strLinks = new Array (


"http://www.commission-junction.com/track/track.dll?AID=10347&PID=296657&URL=http%3A%2F%2Fwww%2Ecj%2Ecom%2FAffiliate%2Finde x%2Easp",


"http://www.bigfoot.com/~java4free.html"


);


//img parts
strImages = new Array (


"http://myserver.co.uk/banners/first1.jpg",
"http://myserver.co.uk/banners/first2.png"


);


//status bar messages
//comment out this block if you don't want status bar messages
strMessages = new Array(


"Commission-Junction. Get paid!",
"Java4Free! Free webtools for webmasters!"


);


function rotateBanner(){


if (bPause){
return;
}


//following code assumes that the banner will be the first link/image
//in your html page. If this is not correct, you will need to modify
//the value in between the [] accordingly. For example, if you have
//2 banners appearing before this banner in your html, you would replace
//the [0] with [2] in the lines below.


document.links[0].href = strLinks[nCurrentBanner];
document.images[0].src = strImages[nCurrentBanner];


//comment out the following line if you don't want status bar messages
window.status = strMessages[nCurrentBanner];


//now rotate for next iteration
if (nCurrentBanner < strLinks.length-1){
nCurrentBanner++;
} else {
nCurrentBanner = 0;
}
}


function pause(){
bPause=true;
}


function resume(){
bPause=false;
}

<WebView android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />

WebView wv = (WebView) findViewById(R.id.webview); WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.setBackgroundColor(Color.TRANSPARENT);
wv.loadUrl("http://myserver.co.uk/banners/banner.html");

haniiii
دوشنبه 22 دی 1393, 11:01 صبح
از این روش هم میتونی استفاده کنی :

wv.loadUrl("http://myserver.co.uk/banners/banner.html");[/JAVA]

خب این روش باید gif رو به صورت jpg قرار بدم ؟

من خود gif رو مستقیم قرار میدم در webview مشکل سایز پیش میاد

haniiii
دوشنبه 22 دی 1393, 11:02 صبح
سلام دوست عزیز
شما باید با استفاده از سورس xml براش انیمیشن طراحی کنید

فکر میکنم استفاده از webview بهتر باشه

big lost
دوشنبه 22 دی 1393, 11:51 صبح
خب این روش باید gif رو به صورت jpg قرار بدم ؟

من خود gif رو مستقیم قرار میدم در webview مشکل سایز پیش میاد

بنر رو به هر فرمتی دوست داشتی میتونی بزاری .
من از فرمت gif استفاده کردم

اگه مشکل سایز داری از کد زیر برای فایل html استفاده کن :


<html><head>
<script src="http://www.sit/banners.js"><style>html { position: relative; width: 320px; height: 50px; height: 100%; }</style></script></head><body style='margin:0;padding:0;' onLoad = "javascript:rotateBanner();javascript:setInterval(' rotateBanner()',10530);"><a href= "http://www.sit.com" onMouseOver = "javascript:pause()" onMouseOut = "javascript:resume()"><img src = "http://www.sit/bander.gif" width="1000" height="150" ></a></body></html>

haniiii
دوشنبه 22 دی 1393, 12:52 عصر
بنر رو به هر فرمتی دوست داشتی میتونی بزاری .
من از فرمت gif استفاده کردم

اگه مشکل سایز داری از کد زیر برای فایل html استفاده کن :


<html><head>
<script src="http://www.sit/banners.js"><style>html { position: relative; width: 320px; height: 50px; height: 100%; }</style></script></head><body style='margin:0;padding:0;' onLoad = "javascript:rotateBanner();javascript:setInterval(' rotateBanner()',10530);"><a href= "http://www.sit.com" onMouseOver = "javascript:pause()" onMouseOut = "javascript:resume()"><img src = "http://www.sit/bander.gif" width="1000" height="150" ></a></body></html>


وقتی طول گوشی بزرگ باشه gif سمت چپ میفته و باقی مونده فضا هم سفید میشه

اما مشکل اصلی سایز وقتی هست که gif بزرگتر از فضای موجود هست ... اگر fit بشه با طول webview حل میشه

big lost
دوشنبه 22 دی 1393, 16:43 عصر
وقتی طول گوشی بزرگ باشه gif سمت چپ میفته و باقی مونده فضا هم سفید میشه

اما مشکل اصلی سایز وقتی هست که gif بزرگتر از فضای موجود هست ... اگر fit بشه با طول webview حل میشه
درسته ، من از سایز 480*60 استفاده میکنم و خیلی خوب نشون میده ، حتی اون فضاهای خالی رو که گفتی برای من نداره

haniiii
یک شنبه 19 بهمن 1393, 21:11 عصر
برای onClick وب ویو چیکار میشه کرد ؟ ...