2012-11-21 72 views
0

我在布局中使用Gallery。当我试图从OnItemSelected函数中更改任何视图(不是图库项目)时,它会影响破碎的画廊动画(出现混乱,并停止看起来平滑)。我的意思是在画廊中选择其他视图后出现的标准画廊动画。Broken Gallery animation

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> 

也许有一种方法来设置上停止动画事件监听器?

另一件事是我的画廊项目上有TextView。 TextColor被设置为黑色,但它仅在画廊中的选定项目为黑色。我如何避免更改未选项目的文字颜色?

谢谢。

回答

0

看起来像原因是所有的意见和画廊都在相对布局链接。在更改一个视图的所有布局重绘和图库本身之后。