How to create half circle filled shape using xml drawable in android?How 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?
Why is it that I can sometimes guess the next note?
What exact color does ozone gas have?
Does IPv6 have similar concept of network mask?
A social experiment. What is the worst that can happen?
Can disgust be a key component of horror?
What should you do when eye contact makes your subordinate uncomfortable?
How to fade a semiplane defined by line?
Why does the Sun have different day lengths, but not the gas giants?
Can I still be respawned if I die by falling off the map?
Unexpected behavior of the procedure `Area` on the object 'Polygon'
Non-trope happy ending?
Can I say "fingers" when referring to toes?
What is the evidence for the "tyranny of the majority problem" in a direct democracy context?
PTIJ: Haman's bad computer
Strong empirical falsification of quantum mechanics based on vacuum energy density
How does a computer interpret real numbers?
Can a stoichiometric mixture of oxygen and methane exist as a liquid at standard pressure and some (low) temperature?
Redundant comparison & "if" before assignment
Why should universal income be universal?
Open a doc from terminal, but not by its name
Does malloc reserve more space while allocating memory?
Fear of getting stuck on one programming language / technology that is not used in my country
Is aluminum electrical wire used on aircraft?
Creepy dinosaur pc game identification
How to create half circle filled shape using xml drawable in android?
How 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?
I want to create a half filled circle shape using xml drawble?
Like this
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
add a comment |
I want to create a half filled circle shape using xml drawble?
Like this
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
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 usingvector graphics
– Goku
Mar 7 at 6:42
add a comment |
I want to create a half filled circle shape using xml drawble?
Like this
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
I want to create a half filled circle shape using xml drawble?
Like this
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
android android-drawable shapes
asked Mar 7 at 6:30
GokuGoku
4,71911036
4,71911036
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 usingvector graphics
– Goku
Mar 7 at 6:42
add a comment |
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 usingvector 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
add a comment |
4 Answers
4
active
oldest
votes
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:
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.
This is nice idea but i want use this inside aTextView
asandroid:drawableEnd
so i can't useandroid:rotation="90"
– Goku
Mar 7 at 6:58
Oh, let me update my code.
– Pratik Butani AndroidDev
Mar 7 at 7:05
@Goku Just try as above.
– Pratik Butani AndroidDev
Mar 7 at 7:10
hey thanks for your time i have found how to rotatevector
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 AndroidDev
Mar 7 at 12:34
|
show 1 more comment
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>
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
add a comment |
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
Finally i got solution using layer-list
to Achieve this
- A
LayerDrawable
is adrawable
object that manages an array of otherdrawables
. Eachdrawable
in the list is drawn in the order of the list—the lastdrawable
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
Note : feel free to post answer if you have any other solution's
Warning :Attribute end is only used in API level 23 and higher (current min is 16)
– Pratik Butani AndroidDev
Mar 7 at 6:58
I think you will get error :Element vector is not allowed here
– Pratik Butani AndroidDev
Mar 7 at 7:22
@PratikButani nop there is no error
– Goku
Mar 7 at 7:27
add a comment |
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>
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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:
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.
This is nice idea but i want use this inside aTextView
asandroid:drawableEnd
so i can't useandroid:rotation="90"
– Goku
Mar 7 at 6:58
Oh, let me update my code.
– Pratik Butani AndroidDev
Mar 7 at 7:05
@Goku Just try as above.
– Pratik Butani AndroidDev
Mar 7 at 7:10
hey thanks for your time i have found how to rotatevector
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 AndroidDev
Mar 7 at 12:34
|
show 1 more comment
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:
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.
This is nice idea but i want use this inside aTextView
asandroid:drawableEnd
so i can't useandroid:rotation="90"
– Goku
Mar 7 at 6:58
Oh, let me update my code.
– Pratik Butani AndroidDev
Mar 7 at 7:05
@Goku Just try as above.
– Pratik Butani AndroidDev
Mar 7 at 7:10
hey thanks for your time i have found how to rotatevector
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 AndroidDev
Mar 7 at 12:34
|
show 1 more comment
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:
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.
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:
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.
edited Mar 7 at 7:10
answered Mar 7 at 6:49
Pratik Butani AndroidDevPratik Butani AndroidDev
30.7k26147272
30.7k26147272
This is nice idea but i want use this inside aTextView
asandroid:drawableEnd
so i can't useandroid:rotation="90"
– Goku
Mar 7 at 6:58
Oh, let me update my code.
– Pratik Butani AndroidDev
Mar 7 at 7:05
@Goku Just try as above.
– Pratik Butani AndroidDev
Mar 7 at 7:10
hey thanks for your time i have found how to rotatevector
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 AndroidDev
Mar 7 at 12:34
|
show 1 more comment
This is nice idea but i want use this inside aTextView
asandroid:drawableEnd
so i can't useandroid:rotation="90"
– Goku
Mar 7 at 6:58
Oh, let me update my code.
– Pratik Butani AndroidDev
Mar 7 at 7:05
@Goku Just try as above.
– Pratik Butani AndroidDev
Mar 7 at 7:10
hey thanks for your time i have found how to rotatevector
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 AndroidDev
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 AndroidDev
Mar 7 at 7:05
Oh, let me update my code.
– Pratik Butani AndroidDev
Mar 7 at 7:05
@Goku Just try as above.
– Pratik Butani AndroidDev
Mar 7 at 7:10
@Goku Just try as above.
– Pratik Butani AndroidDev
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 AndroidDev
Mar 7 at 12:34
Here I have posted question and got answer.
– Pratik Butani AndroidDev
Mar 7 at 12:34
|
show 1 more comment
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>
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
add a comment |
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>
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
add a comment |
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>
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>
answered Mar 7 at 6:49
SdghasemiSdghasemi
1,3951321
1,3951321
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
add a comment |
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
add a comment |
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
Finally i got solution using layer-list
to Achieve this
- A
LayerDrawable
is adrawable
object that manages an array of otherdrawables
. Eachdrawable
in the list is drawn in the order of the list—the lastdrawable
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
Note : feel free to post answer if you have any other solution's
Warning :Attribute end is only used in API level 23 and higher (current min is 16)
– Pratik Butani AndroidDev
Mar 7 at 6:58
I think you will get error :Element vector is not allowed here
– Pratik Butani AndroidDev
Mar 7 at 7:22
@PratikButani nop there is no error
– Goku
Mar 7 at 7:27
add a comment |
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
Finally i got solution using layer-list
to Achieve this
- A
LayerDrawable
is adrawable
object that manages an array of otherdrawables
. Eachdrawable
in the list is drawn in the order of the list—the lastdrawable
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
Note : feel free to post answer if you have any other solution's
Warning :Attribute end is only used in API level 23 and higher (current min is 16)
– Pratik Butani AndroidDev
Mar 7 at 6:58
I think you will get error :Element vector is not allowed here
– Pratik Butani AndroidDev
Mar 7 at 7:22
@PratikButani nop there is no error
– Goku
Mar 7 at 7:27
add a comment |
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
Finally i got solution using layer-list
to Achieve this
- A
LayerDrawable
is adrawable
object that manages an array of otherdrawables
. Eachdrawable
in the list is drawn in the order of the list—the lastdrawable
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
Note : feel free to post answer if you have any other solution's
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
Finally i got solution using layer-list
to Achieve this
- A
LayerDrawable
is adrawable
object that manages an array of otherdrawables
. Eachdrawable
in the list is drawn in the order of the list—the lastdrawable
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
Note : feel free to post answer if you have any other solution's
edited Mar 7 at 7:15
answered Mar 7 at 6:48
GokuGoku
4,71911036
4,71911036
Warning :Attribute end is only used in API level 23 and higher (current min is 16)
– Pratik Butani AndroidDev
Mar 7 at 6:58
I think you will get error :Element vector is not allowed here
– Pratik Butani AndroidDev
Mar 7 at 7:22
@PratikButani nop there is no error
– Goku
Mar 7 at 7:27
add a comment |
Warning :Attribute end is only used in API level 23 and higher (current min is 16)
– Pratik Butani AndroidDev
Mar 7 at 6:58
I think you will get error :Element vector is not allowed here
– Pratik Butani AndroidDev
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 AndroidDev
Mar 7 at 6:58
Warning :
Attribute end is only used in API level 23 and higher (current min is 16)
– Pratik Butani AndroidDev
Mar 7 at 6:58
I think you will get error :
Element vector is not allowed here
– Pratik Butani AndroidDev
Mar 7 at 7:22
I think you will get error :
Element vector is not allowed here
– Pratik Butani AndroidDev
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
add a comment |
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>
add a comment |
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>
add a comment |
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>
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>
answered Mar 7 at 16:53
jeevashankarjeevashankar
1238
1238
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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