Eğer bir iç Görünüm ScrollView görünür olup olmadığını kontrol etmek için nasıl?Android: | Netgez.com
SORU
7 Ocak 2011, Cuma


Eğer bir iç Görünüm ScrollView görünür olup olmadığını kontrol etmek için nasıl?Android:

Görünümleri bir dizi tutan bir ScrollView var. Eğer bir görünüm görünür eğer herhangi bir kısmını şu anda ScrollView tarafından görüntülenir (eğer varsa) olup olmadığını belirlemek için muktedir istiyorum. Kod aşağıda bunu yapmak için beklersiniz, değil şaşırtıcı:

Rect bounds = new Rect();
view.getDrawingRect(bounds);

Rect scrollBounds = new Rect(scroll.getScrollX(), scroll.getScrollY(), 
        scroll.getScrollX()   scroll.getWidth(), scroll.getScrollY()   scroll.getHeight());

if(Rect.intersects(scrollBounds, bounds))
{
    //is  visible
}

CEVAP
14 EYLÜL 2012, Cuma


Bu gibi çalışır:

Rect scrollBounds = new Rect();
scrollView.getHitRect(scrollBounds);
if (imageView.getLocalVisibleRect(scrollBounds)) {
    // Any portion of the imageView, even a single pixel, is within the visible window
} else {
    // NONE of the imageView is within the visible window
}

Bunu PaylaÅŸ:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Joseph Herscher

    Joseph Hersc

    14 Mart 2007
  • Rozetked | Обзоры

    Rozetked | Ð

    5 AÄžUSTOS 2011
  • Within Temptation

    Within Tempt

    18 EYLÜL 2006