我創建了包含3個簡單文本視圖的2視圖的圖庫視圖,以呈現我的數據模型中數據的一些 。 在2視圖上調用Invalidate方法時,它就像 視圖失去焦點,在Gallery View中瀏覽時也是如此。圖庫視圖中的視圖在失效或導航時失去「焦點」
「焦點」丟失後,文字變得幾乎不可讀。 (看下面的兩張圖片)
我使用的是Monodroid,但也經常看到Android的例子。
對我的相冊查看代碼:對於這兩種觀點我投入圖庫視圖
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Gallery
android:id="@+id/locationGallery"
android:layout_height="match_parent"
android:layout_width="fill_parent">
</Gallery>
</LinearLayout>
代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:gravity="top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3sp"
android:id="@+id/locationGalleryItem"
>
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textSize="16sp"
/>
<TextView
android:id="@+id/text2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/text1"
android:padding="10dp"
android:textSize="16sp"
/>
<TextView
android:id="@+id/text3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/text2"
android:padding="10dp"
android:textSize="16sp"
/>
</LinearLayout>
使用這是有點bug,當滾動它有點波濤洶涌,有時捕捉到其中一個子視圖。去尋找另一個解決方案。 我在研究圖庫視圖,它似乎沒有默認的焦點功能,所以這可能是爲什麼unselectedAlpha被完全忽略。 – Cheesebaron
所以我最終做出了一個可以在這裏找到的水平分頁器的端口:https://github.com/Cheesebaron/MonoDroid.HorizontalPager – Cheesebaron