2012-05-18 41 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」