I have the following code:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp"/> <size android:height="1dp" /> <solid android:color="#FFF"/> </shape> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background ="@drawable/line"/>
I have two questions:
The <shape> element is where the shape of your drawable is defined and all its nested elements are defined. The android:shape attribute can hold four values: rectangle , oval , ring , or line . If you do not specify a value, it will be a rectangle by default.
Sometimes you want an outline around your shape and to do that you can use the stroke tag. You can specify the width and color of the outline using android:width and android:color.
A ShapeDrawable takes a Shape object and manages its presence on the screen. If no Shape is given, then the ShapeDrawable will default to a RectShape . This object can be defined in an XML file with the <shape> element.
Inside Android Studio go to File -> Settings -> Plugins -> Browse repositories. Search Android Drawable Preview.
1) In order to set the color of the line, you need to define android:color
on the <stroke>
. The <solid>
element is for the background.
2) You can set the opacity of the shape by using color values with an alpha layer, aka #ARGB. In your case, maybe #7FFF.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With