Skip to content
Fix Code Error

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

March 13, 2021 by Code Error
Posted By: Anonymous

I have some problems finding the documentation of the definitions of shapes in XML for Android. I would like to define a simple circle filled with a solid color in an XML File to include it into my layout files.

Sadly the Documentation on android.com does not cover the XML attributes of the Shape classes. I think I should use an ArcShape to draw a circle but there is no explanation on how to set the size, the color, or the angle needed to make a circle out of an Arc.

Solution

This is a simple circle as a drawable in Android.

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

   <solid 
       android:color="#666666"/>

   <size 
       android:width="120dp"
        android:height="120dp"/>
</shape>
Answered By: Anonymous

Related Articles

  • Android App crashes on animated gradient background
  • How to calculate the angle between a line and the…
  • Android Layout Animations from bottom to top and top…
  • Android - styling seek bar
  • How to implement HorizontalScrollView like Gallery?
  • Web colors in an Android color xml resource file
  • How to set dropdown arrow in spinner?
  • Retrieve only the queried element in an object array…
  • android.view.InflateException: Binary XML file line…
  • Android : Fragment doesn't fit into Fragment Container
  • How to create Custom Ratings bar in Android
  • Keras input explanation: input_shape, units,…
  • Text size and different android screen sizes
  • CSS animate a conical gradient as border image
  • Remove Text from the edit text when edit text is focused
  • ListView inside ScrollView is not scrolling on Android
  • Navbar not filling width of page when reduced to mobile view
  • ListView item background via custom selector
  • Godot 3.3.2 - Changing child variables from the…
  • How to center the content inside a linear layout?
  • Fragment Not Showing in the Activity
  • MaterialCardView is in front of NavigationView. How…
  • Adding custom radio buttons in android
  • Having trouble with my nav bar/header, It used to…
  • Render problem in Android Studio arctic fox
  • Android: how to draw a border to a LinearLayout
  • Constraint Layout Vertical Align Center
  • Unable to move from one fragment to another
  • Circle drawing with SVG's arc path
  • Failed to load AppCompat ActionBar with unknown…
  • How to "properly" create a custom object in JavaScript?
  • Animate a UIBezierPath hexagon like UIActivityIndicatorview
  • Joint.js add custom ports with path class. for…
  • onClick for buttons on custom CardView
  • Getting duplicated cardviews using SwipeRefresh Layout
  • How to create EditText with rounded corners?
  • Standard Android Button with a different color
  • Active tab issue on page load HTML
  • Android ListView headers
  • JavaScript OOP in NodeJS: how?
  • How do I keep only the first map and when the game…
  • Pie is not a function in Ember D3 Pie Chart
  • What to change in circular barplot in R?
  • Actix: what's the right way to move shared data into…
  • Unresponsive hamburger icon in HTML
  • Error inflating class android.support.v7.widget.Toolbar?
  • Iron flex layout: not getting the proper layout
  • Fit Image in ImageButton in Android
  • How to prevent scrolling the whole page?
  • Percentage width in a RelativeLayout
  • Error inflating class…
  • Android ViewPager with bottom dots
  • The drawable "ic_settings" in drawable has no…
  • JointJS Element with ports and tool items (delete,…
  • Rounded Button in Android
  • How can I style an Android Switch?
  • performSelector may cause a leak because its…
  • Add ripple effect to my button with button background color?
  • Gridview with two columns and auto resized images
  • Centering in CSS Grid
  • Expected linking error in C++ but executable builds fine
  • Auto-fit TextView for Android
  • Trying to keep dropdown menus flush to the edge of…
  • How to draw another layer of hexagon UIBezier Path…
  • Use of Jquery on scroll event
  • Couldn't load memtrack module Logcat Error
  • Google Maps Android API v2 - Interactive InfoWindow…
  • Android adding simple animations while…
  • How do you rotate canvas element to mouse position,…
  • Vue js vuecli3 application does not work in ie11…
  • Class is not abstract and does not override abstract method
  • java.lang.NullPointerException: Attempt to invoke…
  • Failed linking file resources
  • How to use ScrollView in Android?
  • flutter - add network images in a pdf while creating…
  • python 3.2 UnicodeEncodeError: 'charmap' codec can't…
  • Playing HTML5 video on fullscreen in android webview
  • How to Customize a Progress Bar In Android
  • how to show progress bar(circle) in an activity…
  • Selector on background color of TextView
  • Creating a template class and using it for returning…
  • Unable to run Robolectric and Espresso with a…
  • Android customized button; changing text color
  • Increasing size of semi circle using css
  • Get the ID of a drawable in ImageView
  • Android:java.lang.OutOfMemoryError: Failed to…
  • Android Layout Right Align
  • Managing longs and short orders like LucF PineCoders…
  • GridLayout and Row/Column Span Woe
  • How to lazy load images in ListView in Android
  • Custome drawable Shape android
  • Android: How to Programmatically set the size of a Layout
  • Custom circle button
  • android button selector
  • How to make custom dialog with rounded corners in android
  • Konva JS - How add Shapes custom with input value
  • How to Intialize the Binding Properties in the…
  • How to show title in hover - css / jquery
  • How to implement a ViewPager with different…
  • How to set button click effect in Android?

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How to open link in new tab on html?

Next Post:

Why can’t I use switch statement on a String?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error