【问题标题】:how to set visible/invisible the buttons when i place pointer/touch the buttons?当我放置指针/触摸按钮时如何设置按钮的可见/不可见?
【发布时间】:2012-05-18 18:12:54
【问题描述】:

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

    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 是三个左键,颜色不同。

【问题讨论】:

    标签: android image button


    【解决方案1】:

    最初将两个按钮置于不可见状态...并为按钮和 imageview 实现 ontouch 侦听器...在按钮的 ontouch 中将其设置为可见..在 imageview 的 ontouch 中设置两个按钮又看不见了。。

    【讨论】:

      【解决方案2】:

      你有没有尝试做一个选择器?

      按下 = 真;焦点=真; drawable = "箭头"

      按下 = 假;焦点=假; drawable = "透明"

      【讨论】:

        【解决方案3】:
        Button _button=(Button)findViewById(R.id.button1);
            _button1.setVisibility(View.INVISIBLE);
        

        或者你可以先让它们不可见,然后你可以让它在你想要的任何地方可见

        【讨论】:

          猜你喜欢
          • 2012-01-20
          • 2019-11-04
          • 2015-08-17
          • 2020-11-28
          • 2011-09-02
          • 2016-03-17
          • 1970-01-01
          • 1970-01-01
          • 2018-05-28
          相关资源
          最近更新 更多