12

私は次のようにAndroidのレイアウトを持っています:

<RelativeLayout>

    <Layout
        android:id="@+id/login_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.test.console.LoginFragment"  />

    <Layout
        android:id="@+id/transperent_fragment"
        android:name="com.test.transperentFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/body_texture"
        android:alpha="0.2"> />

</RelativeLayout>

透明なレイヤーに触れると、ログインボタンがクリックされます。 透明なレイアウトに触れた後にログインボタンのクリックを避ける方法

透明なレイヤーに触れると、ログインボタンがクリックされます。透明なレイアウトに触れた後にログインボタンのクリックを避ける方法

4

2 に答える 2

48

下部のレイアウトをクリックできないようにするには、2 つのオプションがあります。

  1. 属性を追加して、最下層(またはボタン)をクリックできないようにしますandroid:clickable="false"
  2. attribute を追加して最上位レイヤーをクリック可能にするandroid:clickable="true"と、タッチが下位レイヤーに渡されなくなります。

それがあなたを助けることを願っています!

于 2013-01-10T07:32:38.360 に答える
0

ログインボタンにwrap_contentを使用する

<Layout
    android:id="@+id/login_fragment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:name="com.test.console.LoginFragment"  />

<Layout
    android:id="@+id/transperent_fragment"
    android:name="com.test.transperentFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/body_texture"
    android:alpha="0.2"> />

于 2016-04-28T01:40:46.343 に答える