0

レイアウトでギャラリーを使用しています。OnItemSelected関数からビュー(ギャラリーアイテムではない)を変更しようとすると、壊れたギャラリーアニメーションに影響します(ジャークが表示され、スムーズに見えなくなります)。ギャラリーで別のビューを選択した後に表示される標準のギャラリーアニメーションを意味します。

mGallery.setOnItemSelectedListener(new OnItemSelectedListener() {

    @Override
    public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long arg3) {
        mTextView1.setText("asda");
    }

    @Override
    public void onNothingSelected(AdapterView<?> arg0) {

    }

});

レイアウトは次のとおりです。

<RelativeLayout
    android:id="@+id/rl1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" 
    android:background="@drawable/p2_bg_nav">

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="10dp"
        android:background="@drawable/p2_btn_nav_xml"
        android:text="Настр."
        android:textColor="#ffffff" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="Мои карты"
        android:textStyle="bold"
        android:textColor="#ffffff"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

<Gallery
    android:id="@+id/gallery"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:spacing="20dp"
    android:padding="20dp"
    android:unselectedAlpha="1.0"
    android:background="#fa0000" />

<ListView
    android:id="@+id/listView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/rl1"
    android:layout_above="@id/gallery"
    android:background="#d8d8d8" >

</ListView>

たぶん、アニメーション停止イベントにリスナーを設定する方法はありますか?

もう1つは、ギャラリーアイテムにTextViewがあることです。TextColorは黒に設定されていますが、ギャラリーで選択したアイテムに対してのみ黒になります。選択されていないアイテムのテキストの色を変更しないようにするにはどうすればよいですか?

ありがとう。

4

1 に答える 1

0

すべてのビューとギャラリーが相対的なレイアウトでリンクされていることが理由のようです。1 つのビューを変更した後、すべてのレイアウトが再描画され、ギャラリー自体も再描画されます。

于 2012-11-27T20:08:42.193 に答える