ripple effect is showing on non-clickable button which is inside a clickable card










0















I have set button property clickable="false" which inside a card, which has a property clickable=true and android:foreground="?android:attr/selectableItemBackground", but when I click on card the button is also showing ripple effect. Here is my code:



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="8dp">

<android.support.v7.widget.CardView
android:id="@+id/payment_card_view"
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="2dp"
card_view:cardBackgroundColor="#fff"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="4dp">

<Button
android:id="@+id/monthlySubscriptionPayButton"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:text="@string/payment_pay_text"
android:textAllCaps="true"
android:textColor="@color/junkart_color"
android:textSize="14sp"
android:clickable="false"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>


Thanks!










share|improve this question


























    0















    I have set button property clickable="false" which inside a card, which has a property clickable=true and android:foreground="?android:attr/selectableItemBackground", but when I click on card the button is also showing ripple effect. Here is my code:



    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_marginTop="8dp">

    <android.support.v7.widget.CardView
    android:id="@+id/payment_card_view"
    android:layout_width="0dp"
    android:layout_height="200dp"
    android:layout_weight="1"
    android:layout_gravity="center_horizontal"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginBottom="8dp"
    card_view:cardCornerRadius="2dp"
    card_view:cardElevation="2dp"
    card_view:cardBackgroundColor="#fff"
    android:clickable="true"
    android:foreground="?android:attr/selectableItemBackground">

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="4dp">

    <Button
    android:id="@+id/monthlySubscriptionPayButton"
    style="?android:attr/borderlessButtonStyle"
    android:layout_width="wrap_content"
    android:layout_height="48dp"
    android:text="@string/payment_pay_text"
    android:textAllCaps="true"
    android:textColor="@color/junkart_color"
    android:textSize="14sp"
    android:clickable="false"/>
    </LinearLayout>
    </LinearLayout>
    </android.support.v7.widget.CardView>
    </LinearLayout>


    Thanks!










    share|improve this question
























      0












      0








      0








      I have set button property clickable="false" which inside a card, which has a property clickable=true and android:foreground="?android:attr/selectableItemBackground", but when I click on card the button is also showing ripple effect. Here is my code:



      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      xmlns:card_view="http://schemas.android.com/apk/res-auto"
      android:layout_marginTop="8dp">

      <android.support.v7.widget.CardView
      android:id="@+id/payment_card_view"
      android:layout_width="0dp"
      android:layout_height="200dp"
      android:layout_weight="1"
      android:layout_gravity="center_horizontal"
      android:layout_marginLeft="8dp"
      android:layout_marginRight="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginBottom="8dp"
      card_view:cardCornerRadius="2dp"
      card_view:cardElevation="2dp"
      card_view:cardBackgroundColor="#fff"
      android:clickable="true"
      android:foreground="?android:attr/selectableItemBackground">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:padding="4dp">

      <Button
      android:id="@+id/monthlySubscriptionPayButton"
      style="?android:attr/borderlessButtonStyle"
      android:layout_width="wrap_content"
      android:layout_height="48dp"
      android:text="@string/payment_pay_text"
      android:textAllCaps="true"
      android:textColor="@color/junkart_color"
      android:textSize="14sp"
      android:clickable="false"/>
      </LinearLayout>
      </LinearLayout>
      </android.support.v7.widget.CardView>
      </LinearLayout>


      Thanks!










      share|improve this question














      I have set button property clickable="false" which inside a card, which has a property clickable=true and android:foreground="?android:attr/selectableItemBackground", but when I click on card the button is also showing ripple effect. Here is my code:



      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      xmlns:card_view="http://schemas.android.com/apk/res-auto"
      android:layout_marginTop="8dp">

      <android.support.v7.widget.CardView
      android:id="@+id/payment_card_view"
      android:layout_width="0dp"
      android:layout_height="200dp"
      android:layout_weight="1"
      android:layout_gravity="center_horizontal"
      android:layout_marginLeft="8dp"
      android:layout_marginRight="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginBottom="8dp"
      card_view:cardCornerRadius="2dp"
      card_view:cardElevation="2dp"
      card_view:cardBackgroundColor="#fff"
      android:clickable="true"
      android:foreground="?android:attr/selectableItemBackground">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:padding="4dp">

      <Button
      android:id="@+id/monthlySubscriptionPayButton"
      style="?android:attr/borderlessButtonStyle"
      android:layout_width="wrap_content"
      android:layout_height="48dp"
      android:text="@string/payment_pay_text"
      android:textAllCaps="true"
      android:textColor="@color/junkart_color"
      android:textSize="14sp"
      android:clickable="false"/>
      </LinearLayout>
      </LinearLayout>
      </android.support.v7.widget.CardView>
      </LinearLayout>


      Thanks!







      android android-layout material-ui






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 28 '17 at 4:28









      Sachin BhandariSachin Bhandari

      17211




      17211






















          2 Answers
          2






          active

          oldest

          votes


















          1














          Set clickable="true" and foreground="?android:attr/selectableItemBackground" value in LinearLayout inside CardView and your problem will be solved.



          Refer below changes I've made in your code:



          <android.support.v7.widget.CardView
          android:id="@+id/payment_card_view"
          android:layout_width="0dp"
          android:layout_height="200dp"
          android:layout_weight="1"
          android:layout_gravity="center_horizontal"
          android:layout_marginLeft="8dp"
          android:layout_marginRight="8dp"
          android:layout_marginStart="8dp"
          android:layout_marginEnd="8dp"
          android:layout_marginBottom="8dp"
          card_view:cardCornerRadius="2dp"
          card_view:cardElevation="2dp"
          card_view:cardBackgroundColor="#fff">

          <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:clickable="true"
          android:foreground="?android:attr/selectableItemBackground">

          <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          android:padding="4dp">

          <Button
          android:id="@+id/monthlySubscriptionPayButton"
          style="?android:attr/borderlessButtonStyle"
          android:layout_width="wrap_content"
          android:layout_height="48dp"
          android:text="@string/payment_pay_text"
          android:textAllCaps="true"
          android:textColor="@color/junkart_color"
          android:textSize="14sp"
          android:clickable="false"/>
          </LinearLayout>
          </LinearLayout>
          </android.support.v7.widget.CardView>


          Hope it helps to you. Let me know if it is solved.






          share|improve this answer























          • That doesn't help, I want click event and ripple on whole card and some of my button @+id/monthlySubscriptionPayButton will be non-clickable and for those I don't want ripple effect. your answer also shows ripple effect on non-clickable button when parent linearlayout touched.

            – Sachin Bhandari
            Jun 28 '17 at 7:00


















          0














          Set clickable attribute false on CardView. If parent view is clickable drawable state change event will dispatch to child view, no matter child view is clickable or not.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44793667%2fripple-effect-is-showing-on-non-clickable-button-which-is-inside-a-clickable-car%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Set clickable="true" and foreground="?android:attr/selectableItemBackground" value in LinearLayout inside CardView and your problem will be solved.



            Refer below changes I've made in your code:



            <android.support.v7.widget.CardView
            android:id="@+id/payment_card_view"
            android:layout_width="0dp"
            android:layout_height="200dp"
            android:layout_weight="1"
            android:layout_gravity="center_horizontal"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginBottom="8dp"
            card_view:cardCornerRadius="2dp"
            card_view:cardElevation="2dp"
            card_view:cardBackgroundColor="#fff">

            <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:clickable="true"
            android:foreground="?android:attr/selectableItemBackground">

            <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="4dp">

            <Button
            android:id="@+id/monthlySubscriptionPayButton"
            style="?android:attr/borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="48dp"
            android:text="@string/payment_pay_text"
            android:textAllCaps="true"
            android:textColor="@color/junkart_color"
            android:textSize="14sp"
            android:clickable="false"/>
            </LinearLayout>
            </LinearLayout>
            </android.support.v7.widget.CardView>


            Hope it helps to you. Let me know if it is solved.






            share|improve this answer























            • That doesn't help, I want click event and ripple on whole card and some of my button @+id/monthlySubscriptionPayButton will be non-clickable and for those I don't want ripple effect. your answer also shows ripple effect on non-clickable button when parent linearlayout touched.

              – Sachin Bhandari
              Jun 28 '17 at 7:00















            1














            Set clickable="true" and foreground="?android:attr/selectableItemBackground" value in LinearLayout inside CardView and your problem will be solved.



            Refer below changes I've made in your code:



            <android.support.v7.widget.CardView
            android:id="@+id/payment_card_view"
            android:layout_width="0dp"
            android:layout_height="200dp"
            android:layout_weight="1"
            android:layout_gravity="center_horizontal"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginBottom="8dp"
            card_view:cardCornerRadius="2dp"
            card_view:cardElevation="2dp"
            card_view:cardBackgroundColor="#fff">

            <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:clickable="true"
            android:foreground="?android:attr/selectableItemBackground">

            <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="4dp">

            <Button
            android:id="@+id/monthlySubscriptionPayButton"
            style="?android:attr/borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="48dp"
            android:text="@string/payment_pay_text"
            android:textAllCaps="true"
            android:textColor="@color/junkart_color"
            android:textSize="14sp"
            android:clickable="false"/>
            </LinearLayout>
            </LinearLayout>
            </android.support.v7.widget.CardView>


            Hope it helps to you. Let me know if it is solved.






            share|improve this answer























            • That doesn't help, I want click event and ripple on whole card and some of my button @+id/monthlySubscriptionPayButton will be non-clickable and for those I don't want ripple effect. your answer also shows ripple effect on non-clickable button when parent linearlayout touched.

              – Sachin Bhandari
              Jun 28 '17 at 7:00













            1












            1








            1







            Set clickable="true" and foreground="?android:attr/selectableItemBackground" value in LinearLayout inside CardView and your problem will be solved.



            Refer below changes I've made in your code:



            <android.support.v7.widget.CardView
            android:id="@+id/payment_card_view"
            android:layout_width="0dp"
            android:layout_height="200dp"
            android:layout_weight="1"
            android:layout_gravity="center_horizontal"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginBottom="8dp"
            card_view:cardCornerRadius="2dp"
            card_view:cardElevation="2dp"
            card_view:cardBackgroundColor="#fff">

            <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:clickable="true"
            android:foreground="?android:attr/selectableItemBackground">

            <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="4dp">

            <Button
            android:id="@+id/monthlySubscriptionPayButton"
            style="?android:attr/borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="48dp"
            android:text="@string/payment_pay_text"
            android:textAllCaps="true"
            android:textColor="@color/junkart_color"
            android:textSize="14sp"
            android:clickable="false"/>
            </LinearLayout>
            </LinearLayout>
            </android.support.v7.widget.CardView>


            Hope it helps to you. Let me know if it is solved.






            share|improve this answer













            Set clickable="true" and foreground="?android:attr/selectableItemBackground" value in LinearLayout inside CardView and your problem will be solved.



            Refer below changes I've made in your code:



            <android.support.v7.widget.CardView
            android:id="@+id/payment_card_view"
            android:layout_width="0dp"
            android:layout_height="200dp"
            android:layout_weight="1"
            android:layout_gravity="center_horizontal"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginBottom="8dp"
            card_view:cardCornerRadius="2dp"
            card_view:cardElevation="2dp"
            card_view:cardBackgroundColor="#fff">

            <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:clickable="true"
            android:foreground="?android:attr/selectableItemBackground">

            <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="4dp">

            <Button
            android:id="@+id/monthlySubscriptionPayButton"
            style="?android:attr/borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="48dp"
            android:text="@string/payment_pay_text"
            android:textAllCaps="true"
            android:textColor="@color/junkart_color"
            android:textSize="14sp"
            android:clickable="false"/>
            </LinearLayout>
            </LinearLayout>
            </android.support.v7.widget.CardView>


            Hope it helps to you. Let me know if it is solved.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 28 '17 at 4:44









            Pankaj LilanPankaj Lilan

            2,19911634




            2,19911634












            • That doesn't help, I want click event and ripple on whole card and some of my button @+id/monthlySubscriptionPayButton will be non-clickable and for those I don't want ripple effect. your answer also shows ripple effect on non-clickable button when parent linearlayout touched.

              – Sachin Bhandari
              Jun 28 '17 at 7:00

















            • That doesn't help, I want click event and ripple on whole card and some of my button @+id/monthlySubscriptionPayButton will be non-clickable and for those I don't want ripple effect. your answer also shows ripple effect on non-clickable button when parent linearlayout touched.

              – Sachin Bhandari
              Jun 28 '17 at 7:00
















            That doesn't help, I want click event and ripple on whole card and some of my button @+id/monthlySubscriptionPayButton will be non-clickable and for those I don't want ripple effect. your answer also shows ripple effect on non-clickable button when parent linearlayout touched.

            – Sachin Bhandari
            Jun 28 '17 at 7:00





            That doesn't help, I want click event and ripple on whole card and some of my button @+id/monthlySubscriptionPayButton will be non-clickable and for those I don't want ripple effect. your answer also shows ripple effect on non-clickable button when parent linearlayout touched.

            – Sachin Bhandari
            Jun 28 '17 at 7:00













            0














            Set clickable attribute false on CardView. If parent view is clickable drawable state change event will dispatch to child view, no matter child view is clickable or not.






            share|improve this answer



























              0














              Set clickable attribute false on CardView. If parent view is clickable drawable state change event will dispatch to child view, no matter child view is clickable or not.






              share|improve this answer

























                0












                0








                0







                Set clickable attribute false on CardView. If parent view is clickable drawable state change event will dispatch to child view, no matter child view is clickable or not.






                share|improve this answer













                Set clickable attribute false on CardView. If parent view is clickable drawable state change event will dispatch to child view, no matter child view is clickable or not.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 3:20









                AlphaBoomAlphaBoom

                465




                465



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44793667%2fripple-effect-is-showing-on-non-clickable-button-which-is-inside-a-clickable-car%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Use pre created SQLite database for Android project in kotlin

                    Darth Vader #20

                    Ondo