How to create half circle filled shape using xml drawable in android?2019 Community Moderator ElectionHow to define a circle shape in an Android xml drawable file?Half circle shape not workhow to draw a half circle in androidAndroid : Rotate Vector Image to 90 degreeHow do save an Android Activity state using save instance state?Why is the Android emulator so slow? How can we speed up the Android emulator?How to convert a Bitmap to Drawable in android?How to convert a Drawable to a Bitmap?How to define a circle shape in an Android xml drawable file?Android Drawable: Specifying shape width in percent in the XML file?How to create a velodrome shape?How to make a pill shaped button in android?android create drawable that is intersection between circle and rectangleHow to create a rounded corner mask as a drawable?

How to create half circle filled shape using xml drawable in android?



2019 Community Moderator ElectionHow to define a circle shape in an Android xml drawable file?Half circle shape not workhow to draw a half circle in androidAndroid : Rotate Vector Image to 90 degreeHow do save an Android Activity state using save instance state?Why is the Android emulator so slow? How can we speed up the Android emulator?How to convert a Bitmap to Drawable in android?How to convert a Drawable to a Bitmap?How to define a circle shape in an Android xml drawable file?Android Drawable: Specifying shape width in percent in the XML file?How to create a velodrome shape?How to make a pill shaped button in android?android create drawable that is intersection between circle and rectangleHow to create a rounded corner mask as a drawable?










2















I want to create a half filled circle shape using xml drawble?



Like this enter image description here



Here is my efforts that i have tried so far



<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FCD83500"/>
<size
android:width="10dp"
android:height="5dp"/>
<corners
android:bottomLeftRadius="50dp"
android:bottomRightRadius="50dp"/>
</shape>


Using above code i can create half circle but i don't know how to make half circle transparent



I have also visited some SO post but unable to find any solution



  • Half circle shape not work

  • how to draw a half circle in android

  • How to define a circle shape in an Android xml drawable file?

If need more information please do let me know. Thanks in advance. Your efforts will be appreciated.










share|improve this question






















  • Is it necessary to use xml drawable? Otherwise, you can use vector graphics as well.

    – Balvinder Singh
    Mar 7 at 6:35











  • @BalvinderSingh feel free to post solution using vector graphics

    – Goku
    Mar 7 at 6:42















2















I want to create a half filled circle shape using xml drawble?



Like this enter image description here



Here is my efforts that i have tried so far



<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FCD83500"/>
<size
android:width="10dp"
android:height="5dp"/>
<corners
android:bottomLeftRadius="50dp"
android:bottomRightRadius="50dp"/>
</shape>


Using above code i can create half circle but i don't know how to make half circle transparent



I have also visited some SO post but unable to find any solution



  • Half circle shape not work

  • how to draw a half circle in android

  • How to define a circle shape in an Android xml drawable file?

If need more information please do let me know. Thanks in advance. Your efforts will be appreciated.










share|improve this question






















  • Is it necessary to use xml drawable? Otherwise, you can use vector graphics as well.

    – Balvinder Singh
    Mar 7 at 6:35











  • @BalvinderSingh feel free to post solution using vector graphics

    – Goku
    Mar 7 at 6:42













2












2








2








I want to create a half filled circle shape using xml drawble?



Like this enter image description here



Here is my efforts that i have tried so far



<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FCD83500"/>
<size
android:width="10dp"
android:height="5dp"/>
<corners
android:bottomLeftRadius="50dp"
android:bottomRightRadius="50dp"/>
</shape>


Using above code i can create half circle but i don't know how to make half circle transparent



I have also visited some SO post but unable to find any solution



  • Half circle shape not work

  • how to draw a half circle in android

  • How to define a circle shape in an Android xml drawable file?

If need more information please do let me know. Thanks in advance. Your efforts will be appreciated.










share|improve this question














I want to create a half filled circle shape using xml drawble?



Like this enter image description here



Here is my efforts that i have tried so far



<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FCD83500"/>
<size
android:width="10dp"
android:height="5dp"/>
<corners
android:bottomLeftRadius="50dp"
android:bottomRightRadius="50dp"/>
</shape>


Using above code i can create half circle but i don't know how to make half circle transparent



I have also visited some SO post but unable to find any solution



  • Half circle shape not work

  • how to draw a half circle in android

  • How to define a circle shape in an Android xml drawable file?

If need more information please do let me know. Thanks in advance. Your efforts will be appreciated.







android android-drawable shapes






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 6:30









GokuGoku

4,69911036




4,69911036












  • Is it necessary to use xml drawable? Otherwise, you can use vector graphics as well.

    – Balvinder Singh
    Mar 7 at 6:35











  • @BalvinderSingh feel free to post solution using vector graphics

    – Goku
    Mar 7 at 6:42

















  • Is it necessary to use xml drawable? Otherwise, you can use vector graphics as well.

    – Balvinder Singh
    Mar 7 at 6:35











  • @BalvinderSingh feel free to post solution using vector graphics

    – Goku
    Mar 7 at 6:42
















Is it necessary to use xml drawable? Otherwise, you can use vector graphics as well.

– Balvinder Singh
Mar 7 at 6:35





Is it necessary to use xml drawable? Otherwise, you can use vector graphics as well.

– Balvinder Singh
Mar 7 at 6:35













@BalvinderSingh feel free to post solution using vector graphics

– Goku
Mar 7 at 6:42





@BalvinderSingh feel free to post solution using vector graphics

– Goku
Mar 7 at 6:42












4 Answers
4






active

oldest

votes


















1














I have created code from Vector Graphics :



<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="314.015"
android:viewportHeight="314.015">
<path
android:fillColor="#FCD83500"
android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
</vector>


Output will be:



enter image description here



Now if you want to display in as per your angle:



You can use as below:



android:rotation="90"


in your ImageView



Update for TextView Drawable:



Create custom method for rotate drawable.



private Drawable rotate(Drawable drawable, int degree) 
Bitmap iconBitmap = ((BitmapDrawable) drawable).getBitmap();

Matrix matrix = new Matrix();
matrix.postRotate(degree);
Bitmap targetBitmap = Bitmap.createBitmap(iconBitmap, 0, 0, iconBitmap.getWidth(), iconBitmap.getHeight(), matrix, true);

return new BitmapDrawable(getResources(), targetBitmap);



Use as below:



Drawable result = rotate(ContextCompat.getDrawable(mContext, R.drawable.ic_round), 90);
yourTextView.setCompoundDrawablesWithIntrinsicBounds(result, null, null, null);



Note: If you will find SVG image as you want then you do now have to
do above code. I have tried to find image but didn't found so Rotation
code is necessary here.




Hope it will help you.



Thank you.






share|improve this answer

























  • This is nice idea but i want use this inside a TextView as android:drawableEnd so i can't use android:rotation="90"

    – Goku
    Mar 7 at 6:58











  • Oh, let me update my code.

    – Pratik Butani
    Mar 7 at 7:05











  • @Goku Just try as above.

    – Pratik Butani
    Mar 7 at 7:10











  • hey thanks for your time i have found how to rotate vector check my below answer +1 for your help

    – Goku
    Mar 7 at 7:17






  • 1





    Here I have posted question and got answer.

    – Pratik Butani
    Mar 7 at 12:34


















0














Try this:



<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<stroke
android:color="#FCD83500"
android:width="1dp"/>
<size
android:width="20dp"
android:height="20dp"/>
<corners
android:radius="50dp"/>
</shape>
</item>
<item android:top="10dp">
<shape android:shape="rectangle">
<solid android:color="#FCD83500"/>
<size
android:width="20dp"
android:height="10dp"/>
<corners
android:bottomLeftRadius="50dp"
android:bottomRightRadius="50dp"/>
</shape>
</item>
</layer-list>





share|improve this answer























  • Thanks, but your code is not working please check the output using your code

    – Goku
    Mar 7 at 6:52












  • @Goku have you checked it on a real device?

    – Sdghasemi
    Mar 7 at 7:00


















0














UPDATE



Use this



<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="90">
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="314.015"
android:viewportHeight="314.015">
<path
android:fillColor="#FCD83500"
android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
</vector>
</rotate>


OUTPUT



enter image description here



Finally i got solution using layer-list to Achieve this



  • A LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.

MY CODE



<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="26px"
android:right="26px">

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="#00006AC5" />
<size
android:width="50dp"
android:height="50dp" />
<stroke
android:width="2dp"
android:color="#00BCD4" />
</shape>

</item>

<item
android:width="50dp"
android:height="25dp"
android:end="2dp"
android:gravity="center"
android:start="2dp"
android:top="22dp">

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#00BCD4" />
<size
android:width="10dp"
android:height="5dp" />
<corners
android:bottomLeftRadius="50dp"
android:bottomRightRadius="50dp" />
</shape>

</item>

</layer-list>


OUTPUT



enter image description here




Note : feel free to post answer if you have any other solution's







share|improve this answer

























  • Warning : Attribute end is only used in API level 23 and higher (current min is 16)

    – Pratik Butani
    Mar 7 at 6:58











  • I think you will get error : Element vector is not allowed here

    – Pratik Butani
    Mar 7 at 7:22











  • @PratikButani nop there is no error

    – Goku
    Mar 7 at 7:27


















0














Use this code to make half circle vector image. if you want to rotate the vector image means use group tag with rotation element . Refer this link



<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"

android:viewportWidth="314.015"
android:viewportHeight="314.015">
<group
android:translateX="314.015"
android:rotation="90">
<path
android:fillColor="#FCD83500"
android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />

</group>
</vector>





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%2f55037399%2fhow-to-create-half-circle-filled-shape-using-xml-drawable-in-android%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









    1














    I have created code from Vector Graphics :



    <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="314.015"
    android:viewportHeight="314.015">
    <path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
    </vector>


    Output will be:



    enter image description here



    Now if you want to display in as per your angle:



    You can use as below:



    android:rotation="90"


    in your ImageView



    Update for TextView Drawable:



    Create custom method for rotate drawable.



    private Drawable rotate(Drawable drawable, int degree) 
    Bitmap iconBitmap = ((BitmapDrawable) drawable).getBitmap();

    Matrix matrix = new Matrix();
    matrix.postRotate(degree);
    Bitmap targetBitmap = Bitmap.createBitmap(iconBitmap, 0, 0, iconBitmap.getWidth(), iconBitmap.getHeight(), matrix, true);

    return new BitmapDrawable(getResources(), targetBitmap);



    Use as below:



    Drawable result = rotate(ContextCompat.getDrawable(mContext, R.drawable.ic_round), 90);
    yourTextView.setCompoundDrawablesWithIntrinsicBounds(result, null, null, null);



    Note: If you will find SVG image as you want then you do now have to
    do above code. I have tried to find image but didn't found so Rotation
    code is necessary here.




    Hope it will help you.



    Thank you.






    share|improve this answer

























    • This is nice idea but i want use this inside a TextView as android:drawableEnd so i can't use android:rotation="90"

      – Goku
      Mar 7 at 6:58











    • Oh, let me update my code.

      – Pratik Butani
      Mar 7 at 7:05











    • @Goku Just try as above.

      – Pratik Butani
      Mar 7 at 7:10











    • hey thanks for your time i have found how to rotate vector check my below answer +1 for your help

      – Goku
      Mar 7 at 7:17






    • 1





      Here I have posted question and got answer.

      – Pratik Butani
      Mar 7 at 12:34















    1














    I have created code from Vector Graphics :



    <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="314.015"
    android:viewportHeight="314.015">
    <path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
    </vector>


    Output will be:



    enter image description here



    Now if you want to display in as per your angle:



    You can use as below:



    android:rotation="90"


    in your ImageView



    Update for TextView Drawable:



    Create custom method for rotate drawable.



    private Drawable rotate(Drawable drawable, int degree) 
    Bitmap iconBitmap = ((BitmapDrawable) drawable).getBitmap();

    Matrix matrix = new Matrix();
    matrix.postRotate(degree);
    Bitmap targetBitmap = Bitmap.createBitmap(iconBitmap, 0, 0, iconBitmap.getWidth(), iconBitmap.getHeight(), matrix, true);

    return new BitmapDrawable(getResources(), targetBitmap);



    Use as below:



    Drawable result = rotate(ContextCompat.getDrawable(mContext, R.drawable.ic_round), 90);
    yourTextView.setCompoundDrawablesWithIntrinsicBounds(result, null, null, null);



    Note: If you will find SVG image as you want then you do now have to
    do above code. I have tried to find image but didn't found so Rotation
    code is necessary here.




    Hope it will help you.



    Thank you.






    share|improve this answer

























    • This is nice idea but i want use this inside a TextView as android:drawableEnd so i can't use android:rotation="90"

      – Goku
      Mar 7 at 6:58











    • Oh, let me update my code.

      – Pratik Butani
      Mar 7 at 7:05











    • @Goku Just try as above.

      – Pratik Butani
      Mar 7 at 7:10











    • hey thanks for your time i have found how to rotate vector check my below answer +1 for your help

      – Goku
      Mar 7 at 7:17






    • 1





      Here I have posted question and got answer.

      – Pratik Butani
      Mar 7 at 12:34













    1












    1








    1







    I have created code from Vector Graphics :



    <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="314.015"
    android:viewportHeight="314.015">
    <path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
    </vector>


    Output will be:



    enter image description here



    Now if you want to display in as per your angle:



    You can use as below:



    android:rotation="90"


    in your ImageView



    Update for TextView Drawable:



    Create custom method for rotate drawable.



    private Drawable rotate(Drawable drawable, int degree) 
    Bitmap iconBitmap = ((BitmapDrawable) drawable).getBitmap();

    Matrix matrix = new Matrix();
    matrix.postRotate(degree);
    Bitmap targetBitmap = Bitmap.createBitmap(iconBitmap, 0, 0, iconBitmap.getWidth(), iconBitmap.getHeight(), matrix, true);

    return new BitmapDrawable(getResources(), targetBitmap);



    Use as below:



    Drawable result = rotate(ContextCompat.getDrawable(mContext, R.drawable.ic_round), 90);
    yourTextView.setCompoundDrawablesWithIntrinsicBounds(result, null, null, null);



    Note: If you will find SVG image as you want then you do now have to
    do above code. I have tried to find image but didn't found so Rotation
    code is necessary here.




    Hope it will help you.



    Thank you.






    share|improve this answer















    I have created code from Vector Graphics :



    <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="314.015"
    android:viewportHeight="314.015">
    <path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
    </vector>


    Output will be:



    enter image description here



    Now if you want to display in as per your angle:



    You can use as below:



    android:rotation="90"


    in your ImageView



    Update for TextView Drawable:



    Create custom method for rotate drawable.



    private Drawable rotate(Drawable drawable, int degree) 
    Bitmap iconBitmap = ((BitmapDrawable) drawable).getBitmap();

    Matrix matrix = new Matrix();
    matrix.postRotate(degree);
    Bitmap targetBitmap = Bitmap.createBitmap(iconBitmap, 0, 0, iconBitmap.getWidth(), iconBitmap.getHeight(), matrix, true);

    return new BitmapDrawable(getResources(), targetBitmap);



    Use as below:



    Drawable result = rotate(ContextCompat.getDrawable(mContext, R.drawable.ic_round), 90);
    yourTextView.setCompoundDrawablesWithIntrinsicBounds(result, null, null, null);



    Note: If you will find SVG image as you want then you do now have to
    do above code. I have tried to find image but didn't found so Rotation
    code is necessary here.




    Hope it will help you.



    Thank you.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 7 at 7:10

























    answered Mar 7 at 6:49









    Pratik ButaniPratik Butani

    30.6k25146272




    30.6k25146272












    • This is nice idea but i want use this inside a TextView as android:drawableEnd so i can't use android:rotation="90"

      – Goku
      Mar 7 at 6:58











    • Oh, let me update my code.

      – Pratik Butani
      Mar 7 at 7:05











    • @Goku Just try as above.

      – Pratik Butani
      Mar 7 at 7:10











    • hey thanks for your time i have found how to rotate vector check my below answer +1 for your help

      – Goku
      Mar 7 at 7:17






    • 1





      Here I have posted question and got answer.

      – Pratik Butani
      Mar 7 at 12:34

















    • This is nice idea but i want use this inside a TextView as android:drawableEnd so i can't use android:rotation="90"

      – Goku
      Mar 7 at 6:58











    • Oh, let me update my code.

      – Pratik Butani
      Mar 7 at 7:05











    • @Goku Just try as above.

      – Pratik Butani
      Mar 7 at 7:10











    • hey thanks for your time i have found how to rotate vector check my below answer +1 for your help

      – Goku
      Mar 7 at 7:17






    • 1





      Here I have posted question and got answer.

      – Pratik Butani
      Mar 7 at 12:34
















    This is nice idea but i want use this inside a TextView as android:drawableEnd so i can't use android:rotation="90"

    – Goku
    Mar 7 at 6:58





    This is nice idea but i want use this inside a TextView as android:drawableEnd so i can't use android:rotation="90"

    – Goku
    Mar 7 at 6:58













    Oh, let me update my code.

    – Pratik Butani
    Mar 7 at 7:05





    Oh, let me update my code.

    – Pratik Butani
    Mar 7 at 7:05













    @Goku Just try as above.

    – Pratik Butani
    Mar 7 at 7:10





    @Goku Just try as above.

    – Pratik Butani
    Mar 7 at 7:10













    hey thanks for your time i have found how to rotate vector check my below answer +1 for your help

    – Goku
    Mar 7 at 7:17





    hey thanks for your time i have found how to rotate vector check my below answer +1 for your help

    – Goku
    Mar 7 at 7:17




    1




    1





    Here I have posted question and got answer.

    – Pratik Butani
    Mar 7 at 12:34





    Here I have posted question and got answer.

    – Pratik Butani
    Mar 7 at 12:34













    0














    Try this:



    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
    <shape android:shape="rectangle">
    <stroke
    android:color="#FCD83500"
    android:width="1dp"/>
    <size
    android:width="20dp"
    android:height="20dp"/>
    <corners
    android:radius="50dp"/>
    </shape>
    </item>
    <item android:top="10dp">
    <shape android:shape="rectangle">
    <solid android:color="#FCD83500"/>
    <size
    android:width="20dp"
    android:height="10dp"/>
    <corners
    android:bottomLeftRadius="50dp"
    android:bottomRightRadius="50dp"/>
    </shape>
    </item>
    </layer-list>





    share|improve this answer























    • Thanks, but your code is not working please check the output using your code

      – Goku
      Mar 7 at 6:52












    • @Goku have you checked it on a real device?

      – Sdghasemi
      Mar 7 at 7:00















    0














    Try this:



    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
    <shape android:shape="rectangle">
    <stroke
    android:color="#FCD83500"
    android:width="1dp"/>
    <size
    android:width="20dp"
    android:height="20dp"/>
    <corners
    android:radius="50dp"/>
    </shape>
    </item>
    <item android:top="10dp">
    <shape android:shape="rectangle">
    <solid android:color="#FCD83500"/>
    <size
    android:width="20dp"
    android:height="10dp"/>
    <corners
    android:bottomLeftRadius="50dp"
    android:bottomRightRadius="50dp"/>
    </shape>
    </item>
    </layer-list>





    share|improve this answer























    • Thanks, but your code is not working please check the output using your code

      – Goku
      Mar 7 at 6:52












    • @Goku have you checked it on a real device?

      – Sdghasemi
      Mar 7 at 7:00













    0












    0








    0







    Try this:



    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
    <shape android:shape="rectangle">
    <stroke
    android:color="#FCD83500"
    android:width="1dp"/>
    <size
    android:width="20dp"
    android:height="20dp"/>
    <corners
    android:radius="50dp"/>
    </shape>
    </item>
    <item android:top="10dp">
    <shape android:shape="rectangle">
    <solid android:color="#FCD83500"/>
    <size
    android:width="20dp"
    android:height="10dp"/>
    <corners
    android:bottomLeftRadius="50dp"
    android:bottomRightRadius="50dp"/>
    </shape>
    </item>
    </layer-list>





    share|improve this answer













    Try this:



    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
    <shape android:shape="rectangle">
    <stroke
    android:color="#FCD83500"
    android:width="1dp"/>
    <size
    android:width="20dp"
    android:height="20dp"/>
    <corners
    android:radius="50dp"/>
    </shape>
    </item>
    <item android:top="10dp">
    <shape android:shape="rectangle">
    <solid android:color="#FCD83500"/>
    <size
    android:width="20dp"
    android:height="10dp"/>
    <corners
    android:bottomLeftRadius="50dp"
    android:bottomRightRadius="50dp"/>
    </shape>
    </item>
    </layer-list>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 7 at 6:49









    SdghasemiSdghasemi

    1,3951220




    1,3951220












    • Thanks, but your code is not working please check the output using your code

      – Goku
      Mar 7 at 6:52












    • @Goku have you checked it on a real device?

      – Sdghasemi
      Mar 7 at 7:00

















    • Thanks, but your code is not working please check the output using your code

      – Goku
      Mar 7 at 6:52












    • @Goku have you checked it on a real device?

      – Sdghasemi
      Mar 7 at 7:00
















    Thanks, but your code is not working please check the output using your code

    – Goku
    Mar 7 at 6:52






    Thanks, but your code is not working please check the output using your code

    – Goku
    Mar 7 at 6:52














    @Goku have you checked it on a real device?

    – Sdghasemi
    Mar 7 at 7:00





    @Goku have you checked it on a real device?

    – Sdghasemi
    Mar 7 at 7:00











    0














    UPDATE



    Use this



    <?xml version="1.0" encoding="utf-8"?>
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="90"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="90">
    <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="314.015"
    android:viewportHeight="314.015">
    <path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
    </vector>
    </rotate>


    OUTPUT



    enter image description here



    Finally i got solution using layer-list to Achieve this



    • A LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.

    MY CODE



    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
    android:left="26px"
    android:right="26px">

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false">
    <solid android:color="#00006AC5" />
    <size
    android:width="50dp"
    android:height="50dp" />
    <stroke
    android:width="2dp"
    android:color="#00BCD4" />
    </shape>

    </item>

    <item
    android:width="50dp"
    android:height="25dp"
    android:end="2dp"
    android:gravity="center"
    android:start="2dp"
    android:top="22dp">

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#00BCD4" />
    <size
    android:width="10dp"
    android:height="5dp" />
    <corners
    android:bottomLeftRadius="50dp"
    android:bottomRightRadius="50dp" />
    </shape>

    </item>

    </layer-list>


    OUTPUT



    enter image description here




    Note : feel free to post answer if you have any other solution's







    share|improve this answer

























    • Warning : Attribute end is only used in API level 23 and higher (current min is 16)

      – Pratik Butani
      Mar 7 at 6:58











    • I think you will get error : Element vector is not allowed here

      – Pratik Butani
      Mar 7 at 7:22











    • @PratikButani nop there is no error

      – Goku
      Mar 7 at 7:27















    0














    UPDATE



    Use this



    <?xml version="1.0" encoding="utf-8"?>
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="90"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="90">
    <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="314.015"
    android:viewportHeight="314.015">
    <path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
    </vector>
    </rotate>


    OUTPUT



    enter image description here



    Finally i got solution using layer-list to Achieve this



    • A LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.

    MY CODE



    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
    android:left="26px"
    android:right="26px">

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false">
    <solid android:color="#00006AC5" />
    <size
    android:width="50dp"
    android:height="50dp" />
    <stroke
    android:width="2dp"
    android:color="#00BCD4" />
    </shape>

    </item>

    <item
    android:width="50dp"
    android:height="25dp"
    android:end="2dp"
    android:gravity="center"
    android:start="2dp"
    android:top="22dp">

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#00BCD4" />
    <size
    android:width="10dp"
    android:height="5dp" />
    <corners
    android:bottomLeftRadius="50dp"
    android:bottomRightRadius="50dp" />
    </shape>

    </item>

    </layer-list>


    OUTPUT



    enter image description here




    Note : feel free to post answer if you have any other solution's







    share|improve this answer

























    • Warning : Attribute end is only used in API level 23 and higher (current min is 16)

      – Pratik Butani
      Mar 7 at 6:58











    • I think you will get error : Element vector is not allowed here

      – Pratik Butani
      Mar 7 at 7:22











    • @PratikButani nop there is no error

      – Goku
      Mar 7 at 7:27













    0












    0








    0







    UPDATE



    Use this



    <?xml version="1.0" encoding="utf-8"?>
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="90"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="90">
    <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="314.015"
    android:viewportHeight="314.015">
    <path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
    </vector>
    </rotate>


    OUTPUT



    enter image description here



    Finally i got solution using layer-list to Achieve this



    • A LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.

    MY CODE



    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
    android:left="26px"
    android:right="26px">

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false">
    <solid android:color="#00006AC5" />
    <size
    android:width="50dp"
    android:height="50dp" />
    <stroke
    android:width="2dp"
    android:color="#00BCD4" />
    </shape>

    </item>

    <item
    android:width="50dp"
    android:height="25dp"
    android:end="2dp"
    android:gravity="center"
    android:start="2dp"
    android:top="22dp">

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#00BCD4" />
    <size
    android:width="10dp"
    android:height="5dp" />
    <corners
    android:bottomLeftRadius="50dp"
    android:bottomRightRadius="50dp" />
    </shape>

    </item>

    </layer-list>


    OUTPUT



    enter image description here




    Note : feel free to post answer if you have any other solution's







    share|improve this answer















    UPDATE



    Use this



    <?xml version="1.0" encoding="utf-8"?>
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="90"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="90">
    <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="314.015"
    android:viewportHeight="314.015">
    <path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
    </vector>
    </rotate>


    OUTPUT



    enter image description here



    Finally i got solution using layer-list to Achieve this



    • A LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.

    MY CODE



    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
    android:left="26px"
    android:right="26px">

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false">
    <solid android:color="#00006AC5" />
    <size
    android:width="50dp"
    android:height="50dp" />
    <stroke
    android:width="2dp"
    android:color="#00BCD4" />
    </shape>

    </item>

    <item
    android:width="50dp"
    android:height="25dp"
    android:end="2dp"
    android:gravity="center"
    android:start="2dp"
    android:top="22dp">

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#00BCD4" />
    <size
    android:width="10dp"
    android:height="5dp" />
    <corners
    android:bottomLeftRadius="50dp"
    android:bottomRightRadius="50dp" />
    </shape>

    </item>

    </layer-list>


    OUTPUT



    enter image description here




    Note : feel free to post answer if you have any other solution's








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 7 at 7:15

























    answered Mar 7 at 6:48









    GokuGoku

    4,69911036




    4,69911036












    • Warning : Attribute end is only used in API level 23 and higher (current min is 16)

      – Pratik Butani
      Mar 7 at 6:58











    • I think you will get error : Element vector is not allowed here

      – Pratik Butani
      Mar 7 at 7:22











    • @PratikButani nop there is no error

      – Goku
      Mar 7 at 7:27

















    • Warning : Attribute end is only used in API level 23 and higher (current min is 16)

      – Pratik Butani
      Mar 7 at 6:58











    • I think you will get error : Element vector is not allowed here

      – Pratik Butani
      Mar 7 at 7:22











    • @PratikButani nop there is no error

      – Goku
      Mar 7 at 7:27
















    Warning : Attribute end is only used in API level 23 and higher (current min is 16)

    – Pratik Butani
    Mar 7 at 6:58





    Warning : Attribute end is only used in API level 23 and higher (current min is 16)

    – Pratik Butani
    Mar 7 at 6:58













    I think you will get error : Element vector is not allowed here

    – Pratik Butani
    Mar 7 at 7:22





    I think you will get error : Element vector is not allowed here

    – Pratik Butani
    Mar 7 at 7:22













    @PratikButani nop there is no error

    – Goku
    Mar 7 at 7:27





    @PratikButani nop there is no error

    – Goku
    Mar 7 at 7:27











    0














    Use this code to make half circle vector image. if you want to rotate the vector image means use group tag with rotation element . Refer this link



    <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"

    android:viewportWidth="314.015"
    android:viewportHeight="314.015">
    <group
    android:translateX="314.015"
    android:rotation="90">
    <path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />

    </group>
    </vector>





    share|improve this answer



























      0














      Use this code to make half circle vector image. if you want to rotate the vector image means use group tag with rotation element . Refer this link



      <vector xmlns:android="http://schemas.android.com/apk/res/android"
      android:width="24dp"
      android:height="24dp"

      android:viewportWidth="314.015"
      android:viewportHeight="314.015">
      <group
      android:translateX="314.015"
      android:rotation="90">
      <path
      android:fillColor="#FCD83500"
      android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />

      </group>
      </vector>





      share|improve this answer

























        0












        0








        0







        Use this code to make half circle vector image. if you want to rotate the vector image means use group tag with rotation element . Refer this link



        <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"

        android:viewportWidth="314.015"
        android:viewportHeight="314.015">
        <group
        android:translateX="314.015"
        android:rotation="90">
        <path
        android:fillColor="#FCD83500"
        android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />

        </group>
        </vector>





        share|improve this answer













        Use this code to make half circle vector image. if you want to rotate the vector image means use group tag with rotation element . Refer this link



        <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"

        android:viewportWidth="314.015"
        android:viewportHeight="314.015">
        <group
        android:translateX="314.015"
        android:rotation="90">
        <path
        android:fillColor="#FCD83500"
        android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />

        </group>
        </vector>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 7 at 16:53









        jeevashankarjeevashankar

        1038




        1038



























            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%2f55037399%2fhow-to-create-half-circle-filled-shape-using-xml-drawable-in-android%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

            How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

            List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229