2012-12-03 47 views
0

我有以下佈局:檢測,如果裏面的ImageView圖像重疊的TextView

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<com.myapp.imagezoom.ImageViewTouch 
    android:id="@+id/image" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 

<TextView 
    android:id="@+id/txtTitle" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|center" 
    android:layout_marginBottom="3dp" 
    android:gravity="center" 
    android:maxLines="2"/> 

<ProgressBar 
    android:id="@+id/loading" 
    style="?android:attr/progressBarStyleLarge" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:visibility="gone" /> 

正如你可以看到有一個可縮放的ImageView。只要不縮放,TextView就會顯示在ImageView下面。如果用戶放大ImageView,它就會放在ImageView上。 如何檢測顯示的ImageView是否與TextView重疊以顯示TextView的背景?

非常感謝

回答

0

你應該添加到您的ImageViewTouch類名爲isZoomed屬性,然後只是驗證是否是真還是假到定製的替代方法或成AsyncTask並設置TextView的背景或任何你想要的那裏。

要了解有關創建自定義替代方法的更多信息,我建議您閱讀this,它只是解釋如何去做。