Trying to get transparent bg for Cardview











up vote
0
down vote

favorite












I have set both the CardView's background and FrameLayout's to transparent yet the result is still a white color bg.



Is this some default behavior? What should I change to my xml layout file for having a transparent bg ?



Layout file :



<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardBackgroundColor="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="140dp"
tools:layout_gravity="center">

<TextView
android:id="@+id/dayID"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/monthID"
android:textColor="@color/link_text_material_light"
android:layout_marginLeft="60dp"
android:textSize="26dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />


<TextView
android:id="@+id/splashID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_gravity="center"
android:gravity="center"
android:padding="20dp"
tools:text="Hero text" />

<TextView
android:id="@+id/sunbathMinsID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_gravity="bottom"
android:gravity="center"
android:padding="20dp"
tools:text="Hero text" />
</FrameLayout>


</android.support.v7.widget.CardView>









share|improve this question






















  • What have you defined in your theme? Is there a white background color?
    – Thomas R.
    Jun 17 '15 at 9:11










  • I havent defines anything. It just extends AppCompat Light with ActionBar : <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    – vicolored
    Jun 17 '15 at 9:14












  • I think white is the default window background color for this theme. Try to override this with "windowBackground" attribute. Set this to transparent.
    – Thomas R.
    Jun 17 '15 at 9:19

















up vote
0
down vote

favorite












I have set both the CardView's background and FrameLayout's to transparent yet the result is still a white color bg.



Is this some default behavior? What should I change to my xml layout file for having a transparent bg ?



Layout file :



<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardBackgroundColor="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="140dp"
tools:layout_gravity="center">

<TextView
android:id="@+id/dayID"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/monthID"
android:textColor="@color/link_text_material_light"
android:layout_marginLeft="60dp"
android:textSize="26dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />


<TextView
android:id="@+id/splashID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_gravity="center"
android:gravity="center"
android:padding="20dp"
tools:text="Hero text" />

<TextView
android:id="@+id/sunbathMinsID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_gravity="bottom"
android:gravity="center"
android:padding="20dp"
tools:text="Hero text" />
</FrameLayout>


</android.support.v7.widget.CardView>









share|improve this question






















  • What have you defined in your theme? Is there a white background color?
    – Thomas R.
    Jun 17 '15 at 9:11










  • I havent defines anything. It just extends AppCompat Light with ActionBar : <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    – vicolored
    Jun 17 '15 at 9:14












  • I think white is the default window background color for this theme. Try to override this with "windowBackground" attribute. Set this to transparent.
    – Thomas R.
    Jun 17 '15 at 9:19















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have set both the CardView's background and FrameLayout's to transparent yet the result is still a white color bg.



Is this some default behavior? What should I change to my xml layout file for having a transparent bg ?



Layout file :



<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardBackgroundColor="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="140dp"
tools:layout_gravity="center">

<TextView
android:id="@+id/dayID"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/monthID"
android:textColor="@color/link_text_material_light"
android:layout_marginLeft="60dp"
android:textSize="26dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />


<TextView
android:id="@+id/splashID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_gravity="center"
android:gravity="center"
android:padding="20dp"
tools:text="Hero text" />

<TextView
android:id="@+id/sunbathMinsID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_gravity="bottom"
android:gravity="center"
android:padding="20dp"
tools:text="Hero text" />
</FrameLayout>


</android.support.v7.widget.CardView>









share|improve this question













I have set both the CardView's background and FrameLayout's to transparent yet the result is still a white color bg.



Is this some default behavior? What should I change to my xml layout file for having a transparent bg ?



Layout file :



<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardBackgroundColor="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="140dp"
tools:layout_gravity="center">

<TextView
android:id="@+id/dayID"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/monthID"
android:textColor="@color/link_text_material_light"
android:layout_marginLeft="60dp"
android:textSize="26dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />


<TextView
android:id="@+id/splashID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_gravity="center"
android:gravity="center"
android:padding="20dp"
tools:text="Hero text" />

<TextView
android:id="@+id/sunbathMinsID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/link_text_material_light"
android:textSize="26dp"
android:layout_gravity="bottom"
android:gravity="center"
android:padding="20dp"
tools:text="Hero text" />
</FrameLayout>


</android.support.v7.widget.CardView>






android






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 17 '15 at 8:57









vicolored

2351519




2351519












  • What have you defined in your theme? Is there a white background color?
    – Thomas R.
    Jun 17 '15 at 9:11










  • I havent defines anything. It just extends AppCompat Light with ActionBar : <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    – vicolored
    Jun 17 '15 at 9:14












  • I think white is the default window background color for this theme. Try to override this with "windowBackground" attribute. Set this to transparent.
    – Thomas R.
    Jun 17 '15 at 9:19




















  • What have you defined in your theme? Is there a white background color?
    – Thomas R.
    Jun 17 '15 at 9:11










  • I havent defines anything. It just extends AppCompat Light with ActionBar : <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    – vicolored
    Jun 17 '15 at 9:14












  • I think white is the default window background color for this theme. Try to override this with "windowBackground" attribute. Set this to transparent.
    – Thomas R.
    Jun 17 '15 at 9:19


















What have you defined in your theme? Is there a white background color?
– Thomas R.
Jun 17 '15 at 9:11




What have you defined in your theme? Is there a white background color?
– Thomas R.
Jun 17 '15 at 9:11












I havent defines anything. It just extends AppCompat Light with ActionBar : <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
– vicolored
Jun 17 '15 at 9:14






I havent defines anything. It just extends AppCompat Light with ActionBar : <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
– vicolored
Jun 17 '15 at 9:14














I think white is the default window background color for this theme. Try to override this with "windowBackground" attribute. Set this to transparent.
– Thomas R.
Jun 17 '15 at 9:19






I think white is the default window background color for this theme. Try to override this with "windowBackground" attribute. Set this to transparent.
– Thomas R.
Jun 17 '15 at 9:19














1 Answer
1






active

oldest

votes

















up vote
0
down vote













A transparent background can be obtained for any number of views within your XML.
This is a decent explanation for an imageview.
Set transparent background of an imageview on Android



Cardviews are a lot the same but have a little different attribute and are explained very well with the "app:cardBackgroundColor= "@android:color/transparent""
See this post for that type of attribute.
Transparent background on CardView - Android



Setting your cardView and the subsequent FrameLayout both to transparent will definitely get the job done and make both views transparent. However, the activity will always have a solid background. The Activity only doesn't have a solid background when you set a resource as the background and the views placed within that Activity will show the current background if they are set to transparent as seen in the links above.



Therefore, even though you have set your "views" to transparent, the Activity will always need a color or image to show the in background. Meaning that, yes you will still have a white background behind your cardView, unless you change that color.






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',
    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%2f30886838%2ftrying-to-get-transparent-bg-for-cardview%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    A transparent background can be obtained for any number of views within your XML.
    This is a decent explanation for an imageview.
    Set transparent background of an imageview on Android



    Cardviews are a lot the same but have a little different attribute and are explained very well with the "app:cardBackgroundColor= "@android:color/transparent""
    See this post for that type of attribute.
    Transparent background on CardView - Android



    Setting your cardView and the subsequent FrameLayout both to transparent will definitely get the job done and make both views transparent. However, the activity will always have a solid background. The Activity only doesn't have a solid background when you set a resource as the background and the views placed within that Activity will show the current background if they are set to transparent as seen in the links above.



    Therefore, even though you have set your "views" to transparent, the Activity will always need a color or image to show the in background. Meaning that, yes you will still have a white background behind your cardView, unless you change that color.






    share|improve this answer

























      up vote
      0
      down vote













      A transparent background can be obtained for any number of views within your XML.
      This is a decent explanation for an imageview.
      Set transparent background of an imageview on Android



      Cardviews are a lot the same but have a little different attribute and are explained very well with the "app:cardBackgroundColor= "@android:color/transparent""
      See this post for that type of attribute.
      Transparent background on CardView - Android



      Setting your cardView and the subsequent FrameLayout both to transparent will definitely get the job done and make both views transparent. However, the activity will always have a solid background. The Activity only doesn't have a solid background when you set a resource as the background and the views placed within that Activity will show the current background if they are set to transparent as seen in the links above.



      Therefore, even though you have set your "views" to transparent, the Activity will always need a color or image to show the in background. Meaning that, yes you will still have a white background behind your cardView, unless you change that color.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        A transparent background can be obtained for any number of views within your XML.
        This is a decent explanation for an imageview.
        Set transparent background of an imageview on Android



        Cardviews are a lot the same but have a little different attribute and are explained very well with the "app:cardBackgroundColor= "@android:color/transparent""
        See this post for that type of attribute.
        Transparent background on CardView - Android



        Setting your cardView and the subsequent FrameLayout both to transparent will definitely get the job done and make both views transparent. However, the activity will always have a solid background. The Activity only doesn't have a solid background when you set a resource as the background and the views placed within that Activity will show the current background if they are set to transparent as seen in the links above.



        Therefore, even though you have set your "views" to transparent, the Activity will always need a color or image to show the in background. Meaning that, yes you will still have a white background behind your cardView, unless you change that color.






        share|improve this answer












        A transparent background can be obtained for any number of views within your XML.
        This is a decent explanation for an imageview.
        Set transparent background of an imageview on Android



        Cardviews are a lot the same but have a little different attribute and are explained very well with the "app:cardBackgroundColor= "@android:color/transparent""
        See this post for that type of attribute.
        Transparent background on CardView - Android



        Setting your cardView and the subsequent FrameLayout both to transparent will definitely get the job done and make both views transparent. However, the activity will always have a solid background. The Activity only doesn't have a solid background when you set a resource as the background and the views placed within that Activity will show the current background if they are set to transparent as seen in the links above.



        Therefore, even though you have set your "views" to transparent, the Activity will always need a color or image to show the in background. Meaning that, yes you will still have a white background behind your cardView, unless you change that color.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 11 at 3:42









        EPAgg

        35




        35






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f30886838%2ftrying-to-get-transparent-bg-for-cardview%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