This question already has answers here:
Android - drawable with rounded corners at the top only
(10 answers)
Closed 4 years ago.
I want to create this shape for my app but I can't create this shape in the editor
Create a drawable called bg_custom_textview.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#color/SomeColor"
/>
<corners
android:topLeftRadius="10dp"
android:topRightRadius="10dp"
/>
</shape>
Use this as your textview background,
<TextView
android:background="#drawable/bg_custom_textview"
/>
Related
This question already has answers here:
How do I create a ListView with rounded corners in Android?
(11 answers)
Closed 2 years ago.
I have this View in Kotlin:
<View
android:id="#+id/DotView"
android:layout_width="6.5dp"
android:layout_height="6.5dp"
android:layout_marginBottom="10dp"
android:layout_gravity="bottom|center_horizontal"
android:background="#color/colorPrimary"
/>
and I need to round the corners since it is a Dot and I have been investigating and testing how I can do it to round the corners but I just can't find the answer.
How can I solve it?
you have to create a drawable shape xml file and set background property of the view to the drawable file!
res/drawable/circle.xml :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:color="#color/colorPrimary" />
</shape>
res/drawable/rounded.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#color/colorPrimary"/>
<corners android:radius="5dp" />
</shape>
and set background to view like this :
<View
android:id="#+id/DotView"
android:layout_width="6.5dp"
android:layout_height="6.5dp"
android:layout_marginBottom="10dp"
android:layout_gravity="bottom|center_horizontal"
android:background="#drawable/rounded"
/>
This question already has answers here:
Rounded corner for textview in android
(12 answers)
Closed 3 years ago.
Could not post it without a link ! sorry !
Use a layer list drawable, something like this :)
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="4dp"
android:top="4dp">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<stroke
android:width="1dp"
android:color="#color/gray" />
<solid android:color="#color/transparent" />
</shape>
This question already has answers here:
How to have EditText with border in Android Lollipop
(6 answers)
Closed 5 years ago.
anybody could tell me, how to put a border in an editText in AndroidStudio?
for example a square in an editText.
It's so easy bro
First step create an shape.xml in your directory drawable
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#android:color/black"/>
</shape>
Second step create your editext in your layout.xml and put background with the shape that you created above
<EditText
android:id="#+id/edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/shape"/>
It's all
just try this one,
first create one XML file, inside drawable folder (use new drawable xml) and add this lines
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"/>
<solid android:color="#000000"/>
<stroke
android:color="#ffffff"
android:width="05dp"/>
<corners android:radius="20dp"/>
then add this line inside Your edittext property
android:background="#drawable/(file_name)"
i don't know what your expecting, maybe it will help you
This question already has answers here:
Android - border for button
(11 answers)
Closed 2 years ago.
Hi I'm covering my ImageView in buttons but while they are so close to each other you cant make out that it is buttons, its just a big red square. I need a quick and easy way to give my buttons borders/edges or something so you can see the different buttons.
Create a Shape in Drawable Resource
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#C0213A" />`<!--Background Color-->`
<stroke android:width="2dip" android:color="#C0213A"/> `<!--Border-->`
</shape>
In your XML
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:background="#drawable/your_shape"> `<!--This is your shape created--`>
There is no border for buttons but you can use shape to make a drawable with border then put it as background for the button.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#color/red" />
<stroke
android:width="1dp"
android:color="#color/black" />
</shape>
This question already has answers here:
banded background with two colors?
(5 answers)
Closed 8 years ago.
In android xml we set the background as following
android:background="#FF88FF"
Now In frameLayout how can I use tow background color. E.g. top 50% should be red bottom 50% should be black
<FrameLayout
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_weight="0.79"
android:background="#FF88FF"
android:padding="25dp" >
</FrameLayout>
How to do this???
You should do the custom drawable, which will include 2 shapes - 2 rectangles. Something like this:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="50dp">
<shape android:shape="rectangle"
android:dither="true">
<solid android:color="color1"/>
</shape>
</item>
<item android:bottom="50dp">
<shape android:shape="rectangle"
android:dither="true">
<solid android:color="color2"/>
</shape>
</item>
</layer-list>
Please note, that absolute values are used here for sizes. For relative sizes I think you should create custom Drawable programmatically by extending Drawable class.