Create a custom shape - android

How to create a custom shape like below image?
Any help would be appreciated.

Make a new class that extends view.
In the onDraw() use moveTo and lineTo to make the exact shape you want.
In your layout, use:
<com.example.yourpackage.YourViewClass android:id...

you should override onDraw() method to create a custom shapes
this page may help you
http://developer.android.com/training/custom-views/custom-drawing.html

You can use this library PathDrawable
PathDrawable is a Drawable that draws simple shapes using Path object.

try this site its generate XML code for Shape
http://angrytools.com/android/button/

Related

How can I make Local view round in Agora?

I created customed RoundSurfaceView, and then,
val surfaceView = RtcEngine.CreateRendererView(baseContext) as RoundSurfaceView
and then, I got this error.
java.lang.ClassCastException: io.agora.rtc.video.ViEAndroidGLES20 cannot be cast to
I expect this kind of shape.
How can I make it? I also tried with custom RoundFrameLayout. But it didn't work.
You can use the SurfaceView inside a CardView and add corner radius to it.

How to Add text after End drawable in Materialtextinput Android

I would like to add text like this, is this possible with MaterialLayout & MaterialTextInput ??
It can be done in two ways.
The more complicated way is to extend the MaterialTextInput and override methods.
The simple way is to put the MaterialTextInput in a FrameLayout along with a TextView with a fixed size. Create a same size dummy Drawable (eg: ColorDrawable) and set it as end drawable.
Comment for further information.

How to give any shape to Views?

How to give any shape to Views in android
I want following background to textview.
You can create shapes using xml drawables in Android.
https://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
But the background you want is not straightforward using xml. So I recommend creating background using any image editor and set it as background of the textview.
Another approach would be to create vector drawable for the required shape which is supported from android API 21. Here is a good tutorial to create your your own shapes and images
https://medium.com/#ali.muzaffar/understanding-vectordrawable-pathdata-commands-in-android-d56a6054610e
To customize a View you should create a custom view. Create a new class by extending the View class, implement all public constructors and override the onDraw function. When using in the layout file give the full path of the custom view:
<com.example.ownview.MyDrawView
android:id="#+id/myDrawView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

How to make a long oval shape with custom shadow in Android

I think i mentioned the name of the shape wrong.
I want to make shape like the following image with shadows in Android,
Sample model
So how to make this type of layout in Android .
thanx for the help!!
You should try this one:
https://github.com/Hitomis/CrazyShadow
By drawable you can generate the shape, and by using this library you will be able to add shadow.
Or:
You can use the library itself.

Android. Is it possible to change part of text in Canvas?

I want to draw text in Canvas. using this code:
canvas.drawText(getString(R.string.test1)+c, 30,320, paint);
a need change of "c" to bold...
Thanks...
the class Paint has method setTypeface , you can pass a Typeface.
code exmaple:
paint.setTypeface(Typeface.DEFAULT_BOLD);
so if you want change part of text, can draw one by one through change the typeface.
also, you can try use html code like <b>c</b>
Canvas.drawText and its various variants do all expect either a String, CharSequence or char[]. All those types do not support Spannable or Stylable objects. Short: It's not possible in the way you want.
You probably can try to implement the suggesstions idiottiger posted.

Categories

Resources