Rounded corners on linearlayout





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have a linear layout with 2 text views that have different background colors. I want to make the whole view (linearlayout) with rounded corners. I tried enclosing it in MaterialCardview (as I was able to achieve that effect when I set the whole fragment layout inside) but for some reason it is not working. What do I need to do to achieve rounded corner on the view?



<android.support.design.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="8dp"
app:cardCornerRadius="20dp"
app:cardElevation="2dp"
app:cardBackgroundColor="@color/Transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

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

<TextView
android:id="@+id/tutTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tutorial_title"
android:text="Text 1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="@color/White"
android:textSize="16sp" />

<TextView
android:id="@+id/tutBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tutorial_body"
android:padding="10dp"
android:drawableLeft="@drawable/image"
android:drawablePadding="10dp"
android:text="This is a hint"
android:textColor="@color/main_dark_grey"
android:textSize="16sp" />
</LinearLayout>

</android.support.design.card.MaterialCardView>


Note: I know some might suggest to use xml drawable with rounded background. This Won't work as the children background color will take over the transparency and will remain sharp edges










share|improve this question























  • its good if you share your expected output as image

    – Nilesh Rathod
    Nov 29 '18 at 6:40











  • why you don't using shape drawable in both of linear and it's child layout?

    – GianhTran
    Nov 29 '18 at 6:45


















0















I have a linear layout with 2 text views that have different background colors. I want to make the whole view (linearlayout) with rounded corners. I tried enclosing it in MaterialCardview (as I was able to achieve that effect when I set the whole fragment layout inside) but for some reason it is not working. What do I need to do to achieve rounded corner on the view?



<android.support.design.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="8dp"
app:cardCornerRadius="20dp"
app:cardElevation="2dp"
app:cardBackgroundColor="@color/Transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

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

<TextView
android:id="@+id/tutTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tutorial_title"
android:text="Text 1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="@color/White"
android:textSize="16sp" />

<TextView
android:id="@+id/tutBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tutorial_body"
android:padding="10dp"
android:drawableLeft="@drawable/image"
android:drawablePadding="10dp"
android:text="This is a hint"
android:textColor="@color/main_dark_grey"
android:textSize="16sp" />
</LinearLayout>

</android.support.design.card.MaterialCardView>


Note: I know some might suggest to use xml drawable with rounded background. This Won't work as the children background color will take over the transparency and will remain sharp edges










share|improve this question























  • its good if you share your expected output as image

    – Nilesh Rathod
    Nov 29 '18 at 6:40











  • why you don't using shape drawable in both of linear and it's child layout?

    – GianhTran
    Nov 29 '18 at 6:45














0












0








0








I have a linear layout with 2 text views that have different background colors. I want to make the whole view (linearlayout) with rounded corners. I tried enclosing it in MaterialCardview (as I was able to achieve that effect when I set the whole fragment layout inside) but for some reason it is not working. What do I need to do to achieve rounded corner on the view?



<android.support.design.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="8dp"
app:cardCornerRadius="20dp"
app:cardElevation="2dp"
app:cardBackgroundColor="@color/Transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

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

<TextView
android:id="@+id/tutTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tutorial_title"
android:text="Text 1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="@color/White"
android:textSize="16sp" />

<TextView
android:id="@+id/tutBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tutorial_body"
android:padding="10dp"
android:drawableLeft="@drawable/image"
android:drawablePadding="10dp"
android:text="This is a hint"
android:textColor="@color/main_dark_grey"
android:textSize="16sp" />
</LinearLayout>

</android.support.design.card.MaterialCardView>


Note: I know some might suggest to use xml drawable with rounded background. This Won't work as the children background color will take over the transparency and will remain sharp edges










share|improve this question














I have a linear layout with 2 text views that have different background colors. I want to make the whole view (linearlayout) with rounded corners. I tried enclosing it in MaterialCardview (as I was able to achieve that effect when I set the whole fragment layout inside) but for some reason it is not working. What do I need to do to achieve rounded corner on the view?



<android.support.design.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="8dp"
app:cardCornerRadius="20dp"
app:cardElevation="2dp"
app:cardBackgroundColor="@color/Transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

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

<TextView
android:id="@+id/tutTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tutorial_title"
android:text="Text 1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="@color/White"
android:textSize="16sp" />

<TextView
android:id="@+id/tutBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tutorial_body"
android:padding="10dp"
android:drawableLeft="@drawable/image"
android:drawablePadding="10dp"
android:text="This is a hint"
android:textColor="@color/main_dark_grey"
android:textSize="16sp" />
</LinearLayout>

</android.support.design.card.MaterialCardView>


Note: I know some might suggest to use xml drawable with rounded background. This Won't work as the children background color will take over the transparency and will remain sharp edges







android android-layout






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 29 '18 at 6:39









SnakeSnake

5,8511075174




5,8511075174













  • its good if you share your expected output as image

    – Nilesh Rathod
    Nov 29 '18 at 6:40











  • why you don't using shape drawable in both of linear and it's child layout?

    – GianhTran
    Nov 29 '18 at 6:45



















  • its good if you share your expected output as image

    – Nilesh Rathod
    Nov 29 '18 at 6:40











  • why you don't using shape drawable in both of linear and it's child layout?

    – GianhTran
    Nov 29 '18 at 6:45

















its good if you share your expected output as image

– Nilesh Rathod
Nov 29 '18 at 6:40





its good if you share your expected output as image

– Nilesh Rathod
Nov 29 '18 at 6:40













why you don't using shape drawable in both of linear and it's child layout?

– GianhTran
Nov 29 '18 at 6:45





why you don't using shape drawable in both of linear and it's child layout?

– GianhTran
Nov 29 '18 at 6:45












4 Answers
4






active

oldest

votes


















0















I want to make the whole view (linearlayout) with rounded corners.




Since the LinearLayout covers all the CardView, then the whole view, is the CardView.
So instead of setting transparent background to the CardView, set it to the LinearLayout, set a background color to the CardView and you will see rounded corners.

If you set transparent color to both the CardView and the LinearLayout how do you expect to see rounded corners since there are no corners?






share|improve this answer


























  • I am expecting the children (which are Textview with background colors) to have rounded corners where they intersect with cardview corners

    – Snake
    Nov 29 '18 at 18:40













  • If you supply 0 margins, the top TextView will have rounded only its top corners and the bottom only its bottom corners. You can't expect the children views to have rounded corners just because the parent view has rounded corners.

    – forpas
    Nov 29 '18 at 18:44











  • Yes, I am looking for the Top textview to have rounded only its top corners and the bottom only its bottom corners. By making the parent view rounded corner, I was hopping it would clip the corners of the children. I did it btw. I added the answer why it didn't seem to work

    – Snake
    Nov 29 '18 at 19:01











  • Then all you had to do is set top margin 0dp for the top TextView and bottom margin 0dp for the bottom TextView.

    – forpas
    Nov 29 '18 at 19:02











  • No setting of 0 margin necessary. What I provided above works apparently but not on Android Studio design screen, only on device. I will accept the answer being the closest to "do nothing, it works as is"

    – Snake
    Nov 29 '18 at 19:05



















1














Try this layout. Hope this is the give you the expected results you want.



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="16dp">



<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/layout_bg"
>
<TextView
android:id="@+id/que"
android:layout_width="match_parent"
android:layout_height="70dp"
android:gravity="center_vertical"
android:paddingLeft="15dp"
android:text="@string/tvque"
android:textColor="#cbd3db" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/layoutbg1"
android:orientation="horizontal">
<TextView
android:id="@+id/des"
android:padding="16dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tvdes"
android:textColor="#2c365a"
/>
</RelativeLayout>

</LinearLayout>


layout_bg



<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#3e4874"/>
<corners android:topLeftRadius="6dp" android:topRightRadius="6dp"
android:bottomLeftRadius="0.1dp" android:bottomRightRadius="0.1dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp"
android:bottom="0dp" />
</shape>


layout_bg1



<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#fff"/>
<corners android:topLeftRadius="0.1dp" android:topRightRadius="0.1dp"
android:bottomLeftRadius="6dp" android:bottomRightRadius="6dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp"
android:bottom="0dp" />
</shape>





share|improve this answer
























  • That solves problem of rounded corners in this example but wouldn't solve it if you have many children. It does not make sense to do relative layout for ever child!. I will +1 though

    – Snake
    Nov 29 '18 at 18:42





















0














res/drawable/background.xml



<shape ... android:shape="rectangle">
<solid android:color="#00ffffff"/>
<corners android:bottomRightRadius="8dp"
android:bottomLeftRadius="8dp"
android:topRightRadius="8dp"
android:topLeftRadius="8dp"/>
</shape>


activity.xml



<LinearLayout
android:layout_width="match_parent"
android:background="@drawable/
android:layout_height="wrap_content"
android:orientation="vertical">





share|improve this answer
























  • Will not work. Read my comment above

    – Snake
    Nov 29 '18 at 18:40



















0














Actually what I posted worked !! For some reason on Android studio design screen, it was not showing. But when I run it on device, it rounds the corners!






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%2f53533199%2frounded-corners-on-linearlayout%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0















    I want to make the whole view (linearlayout) with rounded corners.




    Since the LinearLayout covers all the CardView, then the whole view, is the CardView.
    So instead of setting transparent background to the CardView, set it to the LinearLayout, set a background color to the CardView and you will see rounded corners.

    If you set transparent color to both the CardView and the LinearLayout how do you expect to see rounded corners since there are no corners?






    share|improve this answer


























    • I am expecting the children (which are Textview with background colors) to have rounded corners where they intersect with cardview corners

      – Snake
      Nov 29 '18 at 18:40













    • If you supply 0 margins, the top TextView will have rounded only its top corners and the bottom only its bottom corners. You can't expect the children views to have rounded corners just because the parent view has rounded corners.

      – forpas
      Nov 29 '18 at 18:44











    • Yes, I am looking for the Top textview to have rounded only its top corners and the bottom only its bottom corners. By making the parent view rounded corner, I was hopping it would clip the corners of the children. I did it btw. I added the answer why it didn't seem to work

      – Snake
      Nov 29 '18 at 19:01











    • Then all you had to do is set top margin 0dp for the top TextView and bottom margin 0dp for the bottom TextView.

      – forpas
      Nov 29 '18 at 19:02











    • No setting of 0 margin necessary. What I provided above works apparently but not on Android Studio design screen, only on device. I will accept the answer being the closest to "do nothing, it works as is"

      – Snake
      Nov 29 '18 at 19:05
















    0















    I want to make the whole view (linearlayout) with rounded corners.




    Since the LinearLayout covers all the CardView, then the whole view, is the CardView.
    So instead of setting transparent background to the CardView, set it to the LinearLayout, set a background color to the CardView and you will see rounded corners.

    If you set transparent color to both the CardView and the LinearLayout how do you expect to see rounded corners since there are no corners?






    share|improve this answer


























    • I am expecting the children (which are Textview with background colors) to have rounded corners where they intersect with cardview corners

      – Snake
      Nov 29 '18 at 18:40













    • If you supply 0 margins, the top TextView will have rounded only its top corners and the bottom only its bottom corners. You can't expect the children views to have rounded corners just because the parent view has rounded corners.

      – forpas
      Nov 29 '18 at 18:44











    • Yes, I am looking for the Top textview to have rounded only its top corners and the bottom only its bottom corners. By making the parent view rounded corner, I was hopping it would clip the corners of the children. I did it btw. I added the answer why it didn't seem to work

      – Snake
      Nov 29 '18 at 19:01











    • Then all you had to do is set top margin 0dp for the top TextView and bottom margin 0dp for the bottom TextView.

      – forpas
      Nov 29 '18 at 19:02











    • No setting of 0 margin necessary. What I provided above works apparently but not on Android Studio design screen, only on device. I will accept the answer being the closest to "do nothing, it works as is"

      – Snake
      Nov 29 '18 at 19:05














    0












    0








    0








    I want to make the whole view (linearlayout) with rounded corners.




    Since the LinearLayout covers all the CardView, then the whole view, is the CardView.
    So instead of setting transparent background to the CardView, set it to the LinearLayout, set a background color to the CardView and you will see rounded corners.

    If you set transparent color to both the CardView and the LinearLayout how do you expect to see rounded corners since there are no corners?






    share|improve this answer
















    I want to make the whole view (linearlayout) with rounded corners.




    Since the LinearLayout covers all the CardView, then the whole view, is the CardView.
    So instead of setting transparent background to the CardView, set it to the LinearLayout, set a background color to the CardView and you will see rounded corners.

    If you set transparent color to both the CardView and the LinearLayout how do you expect to see rounded corners since there are no corners?







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 29 '18 at 8:09

























    answered Nov 29 '18 at 6:51









    forpasforpas

    19.9k4830




    19.9k4830













    • I am expecting the children (which are Textview with background colors) to have rounded corners where they intersect with cardview corners

      – Snake
      Nov 29 '18 at 18:40













    • If you supply 0 margins, the top TextView will have rounded only its top corners and the bottom only its bottom corners. You can't expect the children views to have rounded corners just because the parent view has rounded corners.

      – forpas
      Nov 29 '18 at 18:44











    • Yes, I am looking for the Top textview to have rounded only its top corners and the bottom only its bottom corners. By making the parent view rounded corner, I was hopping it would clip the corners of the children. I did it btw. I added the answer why it didn't seem to work

      – Snake
      Nov 29 '18 at 19:01











    • Then all you had to do is set top margin 0dp for the top TextView and bottom margin 0dp for the bottom TextView.

      – forpas
      Nov 29 '18 at 19:02











    • No setting of 0 margin necessary. What I provided above works apparently but not on Android Studio design screen, only on device. I will accept the answer being the closest to "do nothing, it works as is"

      – Snake
      Nov 29 '18 at 19:05



















    • I am expecting the children (which are Textview with background colors) to have rounded corners where they intersect with cardview corners

      – Snake
      Nov 29 '18 at 18:40













    • If you supply 0 margins, the top TextView will have rounded only its top corners and the bottom only its bottom corners. You can't expect the children views to have rounded corners just because the parent view has rounded corners.

      – forpas
      Nov 29 '18 at 18:44











    • Yes, I am looking for the Top textview to have rounded only its top corners and the bottom only its bottom corners. By making the parent view rounded corner, I was hopping it would clip the corners of the children. I did it btw. I added the answer why it didn't seem to work

      – Snake
      Nov 29 '18 at 19:01











    • Then all you had to do is set top margin 0dp for the top TextView and bottom margin 0dp for the bottom TextView.

      – forpas
      Nov 29 '18 at 19:02











    • No setting of 0 margin necessary. What I provided above works apparently but not on Android Studio design screen, only on device. I will accept the answer being the closest to "do nothing, it works as is"

      – Snake
      Nov 29 '18 at 19:05

















    I am expecting the children (which are Textview with background colors) to have rounded corners where they intersect with cardview corners

    – Snake
    Nov 29 '18 at 18:40







    I am expecting the children (which are Textview with background colors) to have rounded corners where they intersect with cardview corners

    – Snake
    Nov 29 '18 at 18:40















    If you supply 0 margins, the top TextView will have rounded only its top corners and the bottom only its bottom corners. You can't expect the children views to have rounded corners just because the parent view has rounded corners.

    – forpas
    Nov 29 '18 at 18:44





    If you supply 0 margins, the top TextView will have rounded only its top corners and the bottom only its bottom corners. You can't expect the children views to have rounded corners just because the parent view has rounded corners.

    – forpas
    Nov 29 '18 at 18:44













    Yes, I am looking for the Top textview to have rounded only its top corners and the bottom only its bottom corners. By making the parent view rounded corner, I was hopping it would clip the corners of the children. I did it btw. I added the answer why it didn't seem to work

    – Snake
    Nov 29 '18 at 19:01





    Yes, I am looking for the Top textview to have rounded only its top corners and the bottom only its bottom corners. By making the parent view rounded corner, I was hopping it would clip the corners of the children. I did it btw. I added the answer why it didn't seem to work

    – Snake
    Nov 29 '18 at 19:01













    Then all you had to do is set top margin 0dp for the top TextView and bottom margin 0dp for the bottom TextView.

    – forpas
    Nov 29 '18 at 19:02





    Then all you had to do is set top margin 0dp for the top TextView and bottom margin 0dp for the bottom TextView.

    – forpas
    Nov 29 '18 at 19:02













    No setting of 0 margin necessary. What I provided above works apparently but not on Android Studio design screen, only on device. I will accept the answer being the closest to "do nothing, it works as is"

    – Snake
    Nov 29 '18 at 19:05





    No setting of 0 margin necessary. What I provided above works apparently but not on Android Studio design screen, only on device. I will accept the answer being the closest to "do nothing, it works as is"

    – Snake
    Nov 29 '18 at 19:05













    1














    Try this layout. Hope this is the give you the expected results you want.



    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_margin="16dp">



    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/layout_bg"
    >
    <TextView
    android:id="@+id/que"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:gravity="center_vertical"
    android:paddingLeft="15dp"
    android:text="@string/tvque"
    android:textColor="#cbd3db" />
    </RelativeLayout>
    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/layoutbg1"
    android:orientation="horizontal">
    <TextView
    android:id="@+id/des"
    android:padding="16dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/tvdes"
    android:textColor="#2c365a"
    />
    </RelativeLayout>

    </LinearLayout>


    layout_bg



    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#3e4874"/>
    <corners android:topLeftRadius="6dp" android:topRightRadius="6dp"
    android:bottomLeftRadius="0.1dp" android:bottomRightRadius="0.1dp"/>
    <padding android:left="0dp" android:top="0dp" android:right="0dp"
    android:bottom="0dp" />
    </shape>


    layout_bg1



    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#fff"/>
    <corners android:topLeftRadius="0.1dp" android:topRightRadius="0.1dp"
    android:bottomLeftRadius="6dp" android:bottomRightRadius="6dp"/>
    <padding android:left="0dp" android:top="0dp" android:right="0dp"
    android:bottom="0dp" />
    </shape>





    share|improve this answer
























    • That solves problem of rounded corners in this example but wouldn't solve it if you have many children. It does not make sense to do relative layout for ever child!. I will +1 though

      – Snake
      Nov 29 '18 at 18:42


















    1














    Try this layout. Hope this is the give you the expected results you want.



    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_margin="16dp">



    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/layout_bg"
    >
    <TextView
    android:id="@+id/que"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:gravity="center_vertical"
    android:paddingLeft="15dp"
    android:text="@string/tvque"
    android:textColor="#cbd3db" />
    </RelativeLayout>
    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/layoutbg1"
    android:orientation="horizontal">
    <TextView
    android:id="@+id/des"
    android:padding="16dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/tvdes"
    android:textColor="#2c365a"
    />
    </RelativeLayout>

    </LinearLayout>


    layout_bg



    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#3e4874"/>
    <corners android:topLeftRadius="6dp" android:topRightRadius="6dp"
    android:bottomLeftRadius="0.1dp" android:bottomRightRadius="0.1dp"/>
    <padding android:left="0dp" android:top="0dp" android:right="0dp"
    android:bottom="0dp" />
    </shape>


    layout_bg1



    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#fff"/>
    <corners android:topLeftRadius="0.1dp" android:topRightRadius="0.1dp"
    android:bottomLeftRadius="6dp" android:bottomRightRadius="6dp"/>
    <padding android:left="0dp" android:top="0dp" android:right="0dp"
    android:bottom="0dp" />
    </shape>





    share|improve this answer
























    • That solves problem of rounded corners in this example but wouldn't solve it if you have many children. It does not make sense to do relative layout for ever child!. I will +1 though

      – Snake
      Nov 29 '18 at 18:42
















    1












    1








    1







    Try this layout. Hope this is the give you the expected results you want.



    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_margin="16dp">



    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/layout_bg"
    >
    <TextView
    android:id="@+id/que"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:gravity="center_vertical"
    android:paddingLeft="15dp"
    android:text="@string/tvque"
    android:textColor="#cbd3db" />
    </RelativeLayout>
    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/layoutbg1"
    android:orientation="horizontal">
    <TextView
    android:id="@+id/des"
    android:padding="16dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/tvdes"
    android:textColor="#2c365a"
    />
    </RelativeLayout>

    </LinearLayout>


    layout_bg



    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#3e4874"/>
    <corners android:topLeftRadius="6dp" android:topRightRadius="6dp"
    android:bottomLeftRadius="0.1dp" android:bottomRightRadius="0.1dp"/>
    <padding android:left="0dp" android:top="0dp" android:right="0dp"
    android:bottom="0dp" />
    </shape>


    layout_bg1



    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#fff"/>
    <corners android:topLeftRadius="0.1dp" android:topRightRadius="0.1dp"
    android:bottomLeftRadius="6dp" android:bottomRightRadius="6dp"/>
    <padding android:left="0dp" android:top="0dp" android:right="0dp"
    android:bottom="0dp" />
    </shape>





    share|improve this answer













    Try this layout. Hope this is the give you the expected results you want.



    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_margin="16dp">



    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/layout_bg"
    >
    <TextView
    android:id="@+id/que"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:gravity="center_vertical"
    android:paddingLeft="15dp"
    android:text="@string/tvque"
    android:textColor="#cbd3db" />
    </RelativeLayout>
    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/layoutbg1"
    android:orientation="horizontal">
    <TextView
    android:id="@+id/des"
    android:padding="16dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/tvdes"
    android:textColor="#2c365a"
    />
    </RelativeLayout>

    </LinearLayout>


    layout_bg



    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#3e4874"/>
    <corners android:topLeftRadius="6dp" android:topRightRadius="6dp"
    android:bottomLeftRadius="0.1dp" android:bottomRightRadius="0.1dp"/>
    <padding android:left="0dp" android:top="0dp" android:right="0dp"
    android:bottom="0dp" />
    </shape>


    layout_bg1



    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#fff"/>
    <corners android:topLeftRadius="0.1dp" android:topRightRadius="0.1dp"
    android:bottomLeftRadius="6dp" android:bottomRightRadius="6dp"/>
    <padding android:left="0dp" android:top="0dp" android:right="0dp"
    android:bottom="0dp" />
    </shape>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 29 '18 at 7:17









    asif aliasif ali

    1114




    1114













    • That solves problem of rounded corners in this example but wouldn't solve it if you have many children. It does not make sense to do relative layout for ever child!. I will +1 though

      – Snake
      Nov 29 '18 at 18:42





















    • That solves problem of rounded corners in this example but wouldn't solve it if you have many children. It does not make sense to do relative layout for ever child!. I will +1 though

      – Snake
      Nov 29 '18 at 18:42



















    That solves problem of rounded corners in this example but wouldn't solve it if you have many children. It does not make sense to do relative layout for ever child!. I will +1 though

    – Snake
    Nov 29 '18 at 18:42







    That solves problem of rounded corners in this example but wouldn't solve it if you have many children. It does not make sense to do relative layout for ever child!. I will +1 though

    – Snake
    Nov 29 '18 at 18:42













    0














    res/drawable/background.xml



    <shape ... android:shape="rectangle">
    <solid android:color="#00ffffff"/>
    <corners android:bottomRightRadius="8dp"
    android:bottomLeftRadius="8dp"
    android:topRightRadius="8dp"
    android:topLeftRadius="8dp"/>
    </shape>


    activity.xml



    <LinearLayout
    android:layout_width="match_parent"
    android:background="@drawable/
    android:layout_height="wrap_content"
    android:orientation="vertical">





    share|improve this answer
























    • Will not work. Read my comment above

      – Snake
      Nov 29 '18 at 18:40
















    0














    res/drawable/background.xml



    <shape ... android:shape="rectangle">
    <solid android:color="#00ffffff"/>
    <corners android:bottomRightRadius="8dp"
    android:bottomLeftRadius="8dp"
    android:topRightRadius="8dp"
    android:topLeftRadius="8dp"/>
    </shape>


    activity.xml



    <LinearLayout
    android:layout_width="match_parent"
    android:background="@drawable/
    android:layout_height="wrap_content"
    android:orientation="vertical">





    share|improve this answer
























    • Will not work. Read my comment above

      – Snake
      Nov 29 '18 at 18:40














    0












    0








    0







    res/drawable/background.xml



    <shape ... android:shape="rectangle">
    <solid android:color="#00ffffff"/>
    <corners android:bottomRightRadius="8dp"
    android:bottomLeftRadius="8dp"
    android:topRightRadius="8dp"
    android:topLeftRadius="8dp"/>
    </shape>


    activity.xml



    <LinearLayout
    android:layout_width="match_parent"
    android:background="@drawable/
    android:layout_height="wrap_content"
    android:orientation="vertical">





    share|improve this answer













    res/drawable/background.xml



    <shape ... android:shape="rectangle">
    <solid android:color="#00ffffff"/>
    <corners android:bottomRightRadius="8dp"
    android:bottomLeftRadius="8dp"
    android:topRightRadius="8dp"
    android:topLeftRadius="8dp"/>
    </shape>


    activity.xml



    <LinearLayout
    android:layout_width="match_parent"
    android:background="@drawable/
    android:layout_height="wrap_content"
    android:orientation="vertical">






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 29 '18 at 7:25









    Мағжан АмангелдіұлыМағжан Амангелдіұлы

    11




    11













    • Will not work. Read my comment above

      – Snake
      Nov 29 '18 at 18:40



















    • Will not work. Read my comment above

      – Snake
      Nov 29 '18 at 18:40

















    Will not work. Read my comment above

    – Snake
    Nov 29 '18 at 18:40





    Will not work. Read my comment above

    – Snake
    Nov 29 '18 at 18:40











    0














    Actually what I posted worked !! For some reason on Android studio design screen, it was not showing. But when I run it on device, it rounds the corners!






    share|improve this answer




























      0














      Actually what I posted worked !! For some reason on Android studio design screen, it was not showing. But when I run it on device, it rounds the corners!






      share|improve this answer


























        0












        0








        0







        Actually what I posted worked !! For some reason on Android studio design screen, it was not showing. But when I run it on device, it rounds the corners!






        share|improve this answer













        Actually what I posted worked !! For some reason on Android studio design screen, it was not showing. But when I run it on device, it rounds the corners!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 29 '18 at 18:43









        SnakeSnake

        5,8511075174




        5,8511075174






























            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%2f53533199%2frounded-corners-on-linearlayout%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

            Lallio

            Unable to find Lightning Node

            Futebolista