I'm trying to do this for months and finally i can't find anyway. Elevation is just for API 21+ and other ways sometimes work and sometimes doesn't. I'm working on a music player and i need shadow between music controller and musics cover. How to add shadow? elevation doesn't work here as you can see
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<ImageView
android:id="#+id/now.playing.cover"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:scaleType="centerInside"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="8dp">
<TextView
android:id="#+id/now.title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="#color/colorSecondaryText" />
<TextView
android:id="#+id/now.artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="#color/colorSecondaryText" />
<TextView
android:id="#+id/now.album"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="#color/colorSecondaryText" />
<android.support.v7.widget.AppCompatSeekBar
android:id="#+id/now.seek"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="32dp"
android:layout_marginTop="8dp"
android:paddingRight="32dp">
<ImageView
android:id="#+id/prev"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginRight="56dp"
android:padding="2dp"
android:src="#drawable/prev" />
<ImageView
android:id="#+id/pp"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginRight="56dp"
android:padding="2dp"
android:src="#drawable/play" />
<ImageView
android:id="#+id/next"
android:layout_width="36dp"
android:layout_height="36dp"
android:padding="2dp"
android:src="#drawable/next" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
You can add a view in between which looks like shadow..
Below is an example of same which I have used and it almost works on all the apis.. May be it can help you..
Shadow View:
<View
android:id="#+id/toolbar_shadow"
android:layout_width="match_parent"
android:layout_height="15dp"
android:layout_below="#+id/toolbar"
android:background="#drawable/toolbar_shadow" />
And the drawable file:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:endColor="#88444444"
android:startColor="#00000000" />
</shape>
Related
I am working on an android project where i am trying to create an image like a star inside a circle
like this one
I have tried but i am unable to resize the star.
Every time i try to resize star android studio resize my whole image
this is my circle shape 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/darkPurple"/>
<size
android:width="50dp"
android:height="50dp"/>
</shape>
this is my star xml:
<vector android:autoMirrored="true" android:height="1dp"
android:tint="#FFB404" android:viewportHeight="24"
android:viewportWidth="24" android:width="1dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#android:color/white" android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
</vector>
This is my layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:layout_gravity="center"
android:background="#drawable/circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_baseline_star_24"
>
</ImageView>
<TextView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Markets"
android:textColor="#color/white"
>
</TextView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_gravity="center"
android:background="#drawable/circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_baseline_star_24"
>
</ImageView>
<TextView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Markets"
android:textColor="#color/white"
>
</TextView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_gravity="center"
android:background="#drawable/circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_baseline_star_24"
>
</ImageView>
<TextView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Markets"
android:textColor="#color/white"
>
</TextView>
</LinearLayout>
</LinearLayout>
Please tell me how can i do this
I had the similar problem and I fixed it using below methods.
You can either add padding inside your ImageView
<ImageView
android:layout_gravity="center"
android:background="#drawable/circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_baseline_star_24"
android:padding="16dp"> <!-- Here is the change -->
or set scaleType attribute in ImageView to fit according to your need.
<ImageView
android:layout_gravity="center"
android:background="#drawable/circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_baseline_star_24"
android:scaleType="centerInside"> <!-- Here is the change -->
I need to build a searchview who is fixed on top of the page.
When i scroll down my searchview is overlapped by a imageslider Image 1 all i need to do is to be always in front to be visible.
I tried everything but always my searchview is in the back of other objects. Any suggestions?
This is my xml file.
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:src="#drawable/logo" />
<SearchView
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="#string/searchint"
android:background="#drawable/bg_round"
android:queryBackground="#color/transparent"
android:queryHint="SEARCH PRODUCTS"
android:theme="#style/SearchViewStyle" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autofillHints="#string/email"
android:drawableStart="#drawable/email"
android:drawablePadding="10sp"
android:ems="10"
android:hint="#string/email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:padding="20sp"
android:textColor="#color/white"
android:textColorHint="#color/white" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:autofillHints="#string/parola"
android:drawablePadding="10sp"
android:ems="10"
android:hint="#string/parola"
android:inputType="textPassword"
android:maxLines="1"
android:padding="20sp"
android:textColor="#color/white"
android:textColorHint="#color/white" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:buttonTint="#color/white"
android:paddingStart="30sp"
android:textColor="#color/white" />
</LinearLayout>
<com.denzcoskun.imageslider.ImageSlider
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:iss_auto_cycle="true"
app:iss_corner_radius="5"
app:iss_delay="0"
app:iss_period="1000"></com.denzcoskun.imageslider.ImageSlider>
</LinearLayout>
</ScrollView>
</androidx.drawerlayout.widget.DrawerLayout>
You can use elevation to make it at top of other elements
Solution Code:
<SearchView
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="#string/searchint"
android:background="#drawable/bg_round"
android:queryBackground="#color/transparent"
android:elevation="20dp"
android:queryHint="SEARCH PRODUCTS"
android:theme="#style/SearchViewStyle" />
For instance, I used 20dp, you use your preferred value instead.
Feel free to ask if something is unclear.
I use scrollView in my project. There are some questions in textview and answers of question in radioButton. I should add horizontal scrollBar to this layout to show more questions in Activity. But scrollview doesn't work. Also I can't add scrollBar there, that seem doesn't work. I just looked some questions in StackOverflow. According them my codes should work. But it doesn't work. Please help me.
job_security.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="#+id/radio_layout"
android:layout_width="match_parent"
android:layout_height="222dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<TextView
android:id="#+id/textView4"
android:layout_width="360dp"
android:layout_height="26dp"
android:layout_marginTop="20dp"
android:text="#string/job_security_question1"
android:textSize="16sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/job_security_question1.2"
android:textSize="12sp" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/rd1_yes"
android:layout_width="190dp"
android:layout_height="match_parent"
android:buttonTint="#color/colorPrimary"
android:gravity="left|center_vertical"
android:text="#string/radio_yes" />
<RadioButton
android:id="#+id/rd1_no"
android:layout_width="190dp"
android:layout_height="match_parent"
android:buttonTint="#color/colorPrimary"
android:text="#string/radio_no" />
</RadioGroup>
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="#string/job_security_question2" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/rd2_yes"
android:layout_width="190dp"
android:layout_height="match_parent"
android:buttonTint="#color/colorPrimary"
android:gravity="left|center_vertical"
android:text="#string/radio_yes" />
<RadioButton
android:id="#+id/rd2_no"
android:layout_width="190dp"
android:layout_height="match_parent"
android:buttonTint="#color/colorPrimary"
android:text="#string/radio_no" />
</RadioGroup>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<Button
android:id="#+id/btn_login"
style="?android:attr/buttonStyleSmall"
android:layout_width="178dp"
android:layout_height="40dip"
android:layout_centerHorizontal="true"
android:background="#drawable/buton_radious"
android:clickable="true"
android:focusable="true"
android:text="#string/send_button"
android:textColor="#android:color/white"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
Inside ScrollView must contain only one layout!
This sample code solve your problem
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- here add your views -->
</LinearLayout>
</ScrollView>
I have this recyclerview, and the background is made with imageviews. I have these two situations in portrait and landscape. How do I fill the white space there with a new imageview or something with the same color?
And this is my xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/home_imageview_superbackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true" />
<ImageView
android:id="#+id/home_imageview_background"
android:contentDescription="Background image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_alignParentEnd="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true">
<TextView
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="casual"
android:paddingBottom="10dp"
android:paddingStart="5dp"
android:paddingTop="10dp"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="#android:color/white"
android:textSize="40sp" />
</RelativeLayout>
Tried several ways, but I'm just not able to make this work. #+id/home_imageview_superbackground this is the imageview I want to put on the left of each background imageview to fill that space in the landscape. Thank you for the help.
Please try this one
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/home_imageview_superbackground"
android:layout_width="match_parent"
android:src="#mipmap/ic_launcher"
android:scaleType="fitXY"
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/home_imageview_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher"
android:scaleType="fitXY"
android:contentDescription="Background image" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true">
<TextView
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="casual"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="#android:color/white"
android:textSize="40sp" />
</RelativeLayout>
</RelativeLayout>
You can also use android:scaleType="centerCrop".
Hope this will help you..If still you face problem please inform me...
<ImageView
android:layout_width="match_parent"
.... />
Also you can use scaleTypeattribute
First, the fill_parent is deprecated times ago, you should use match_parent instead. Then, you have also to use scaleType when you're working with ImagesView to define how the image looks on the screen. In your case, working with scaleType = "fitXY" solve your problem.
How your code should be :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/home_imageview_superbackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:layout_alignParentStart="true" />
<ImageView
android:id="#+id/home_imageview_background"
android:contentDescription="Background image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:layout_alignParentEnd="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true">
<TextView
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="casual"
android:paddingBottom="10dp"
android:paddingStart="5dp"
android:paddingTop="10dp"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="#android:color/white"
android:textSize="40sp" />
</RelativeLayout>
Try this code
<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/your_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher"
android:scaleType="fitEnd"
android:layout_alignParentStart="true"
android:background="#drawable/green_gradiant"
android:padding="10dp" />
<TextView
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="casual"
android:paddingBottom="10dp"
android:paddingStart="5dp"
android:paddingTop="10dp"
android:text="Hello Three"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="#android:color/white"
android:textSize="40sp" />
</FrameLayout>
And create this drawable file
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient android:angle="0"
android:startColor="#64FFDA"
android:centerColor="#4464FFDA"
android:endColor="#0064FFDA"/>
</shape>
</item>
</selector>
I want to do this :
I did this :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_aplication_settings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e2e2e2"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.smok.maps.AplicationSettings">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<TextView
android:id="#+id/textSync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="#string/sync" />
<LinearLayout
android:id="#+id/line1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textSync">
<TextView
android:id="#+id/actual"
android:layout_width="wrap_content"
android:textColor="#000000"
android:layout_height="wrap_content"
android:text="#string/actual" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/count" />
<TextView
android:id="#+id/actual2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="min" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/line1"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox1"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="#xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/point" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#000000"
android:text="#string/show_choose_point" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lin2"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="#xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/sync" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:gravity="center"
android:text="#string/sync_request" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lin3"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="#xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/show_chooce" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:gravity="center"
android:text="#string/show_choosen_points" />
</LinearLayout>
<LinearLayout
android:id="#+id/lin5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lin4"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox4"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="#xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/position2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#000000"
android:text="#string/current_location" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:orientation="horizontal">
<Button
android:id="#+id/back_bt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#ffffff"
android:background="#xml/roundedbutton"
android:text="#string/back" />
<View
android:layout_width="0dp"
android:layout_weight="0.1"
android:layout_height="match_parent">
</View>
<Button
android:id="#+id/confirm_bt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#ffffff"
android:background="#xml/roundedbutton"
android:text="#string/save" />
</LinearLayout>
</RelativeLayout>
I don't have idea how I can do border. I want to do a border and in the middle I want to have place to put text.This same how is in the screen. This look like a frame which have a text. Now I have onli text and I don not how I can create a frame.
Here is demo of your requirement.
1) You need to create a border.xml. Put this in your drawable folder. Add the following code in border.xml :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!--stroke width and color-->
<stroke
android:width="2dp"
android:color="#android:color/darker_gray" />
<!-- corner radius-->
<corners
android:radius="5dp" />
<!--paddings-->
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
</shape>
2) Here is the layout.xml put the background to a linearlayout accordingly:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="bd.com.tahsin.myapplicationnavgroup.MainActivity"
tools:showIn="#layout/app_bar_main">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:layout_marginTop="5dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:background="#drawable/bottom_border_help">
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MENU_BOCZNE"
android:background="#color/background_floating_material_light"
android:layout_marginLeft="10dp" />
</RelativeLayout>
3) And finally the screen-shot:
Hope, this will help a bit.
Try this,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/border"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="TEST"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text=" MENU "
android:layout_marginLeft="15dp"
android:background="#ffffff"
android:textSize="17sp" />
</RelativeLayout>
xml of border.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="3dp"/>
<stroke
android:width="2dp"
android:color="#cdcdcd" />
</shape>