2012-05-18 42 views
0

我正在制作一个应用程序,我想显示图像列表。通常我可以显示图像。我用左右导航按钮显示了这些图像。以供参考。当我按左键显示上一个和右键显示下一个图像。但实际上我不会总是显示按钮,当我的指针去那里时,它必须可见。 否则只有图像必须显示。 任何想法请 而且我的图像都是不同的大小,我怎么能得到模拟器的大小?那么它很容易调整图像大小并设置在可绘制列表中。当我放置指针/触摸按钮时如何设置可见/不可见按钮?

enter image description here

code for left button: 
    <Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBaseline="@+id/bttn" 
    android:layout_alignBottom="@+id/bttn" 
    android:layout_alignParentRight="true" 
    android:onClick="ClickHandler2" 
    android:background="@drawable/android_lbutton" 
    /> 
    in drawable/android_lbutton 

    <?xml version="1.0" encoding="utf-8"?> 
    <selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@drawable/timthumb6" 
     android:state_pressed="true" /> 
<item android:drawable="@drawable/timthumb3" 
     android:state_focused="true" /> 
<item android:drawable="@drawable/timthumb8" /> 
    </selector> 

这里timthumb6,timthumb3,timthumb8与差异颜色的三个按钮左侧。

+0

把完整的xml代码 – waqaslam

回答

2

把两个隐形状态的按钮开始...和实施ontouch侦听这两个按钮,并为ImageView的以及...在按钮的ontouch设置它可见..并在onview的imageview设置两个按钮不可见再次..

0
Button _button=(Button)findViewById(R.id.button1); 
    _button1.setVisibility(View.INVISIBLE); 

或U可以先放他们看不见那么在哪里使其可见哪里ü希望

+0

你的意思是_button1两次 – keyser

2

你尝试做选择?

Press = true;焦点=真实; drawable =“arrow”

Press = false;焦点=假; drawable =“transparent”