Android: Draw vertical line in a layout
up vote
-1
down vote
favorite
I am trying to draw vertical line in a row layout of the list (Recycler View). The line should be align left of the layout with margin left 20dp and the line height should be auto, when the content of the row layout increasse the vertical line align that align left of the layout also should increase.
I tried to add line by drawing the vertical line in drawable folder and add it to the background of the layout. But the problem is line comes only as the half
Draw able : vertical_line.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:toDegrees="90"
android:pivotX="10">
<shape
android:shape="line">
<stroke
android:width="1dp"
android:color="#ff00ff"
/>
</shape>
Layout
<?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="wrap_content"
android:background="@color/black_two">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:background="@drawable/vertical_line"
>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</RelativeLayout>
Please help me to draw a line on the left of the layout with auto height
add a comment |
up vote
-1
down vote
favorite
I am trying to draw vertical line in a row layout of the list (Recycler View). The line should be align left of the layout with margin left 20dp and the line height should be auto, when the content of the row layout increasse the vertical line align that align left of the layout also should increase.
I tried to add line by drawing the vertical line in drawable folder and add it to the background of the layout. But the problem is line comes only as the half
Draw able : vertical_line.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:toDegrees="90"
android:pivotX="10">
<shape
android:shape="line">
<stroke
android:width="1dp"
android:color="#ff00ff"
/>
</shape>
Layout
<?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="wrap_content"
android:background="@color/black_two">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:background="@drawable/vertical_line"
>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</RelativeLayout>
Please help me to draw a line on the left of the layout with auto height
Do you really a drawable xml to draw a vertical line? Because you can also do that with just views...
– Aaron
Nov 22 at 4:11
Your parentRelativeLayoutheight is "wrap_content " change it to "match_parent" so that it will draw a line on the whole screen
– Akshay Katariya
Nov 22 at 4:12
@ Aaron if we use <View> how to make that height as wrap_content
– Binil Surendran
Nov 22 at 4:16
@Akshay Katariya am using this layout as the row item of my list, so how can i change row parent layout to match_parent?. if so 1 Row consume full height of the view.
– Binil Surendran
Nov 22 at 4:17
@BinilSurendran If you use <View>, just set the height to match_parent.
– Aaron
Nov 22 at 4:18
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am trying to draw vertical line in a row layout of the list (Recycler View). The line should be align left of the layout with margin left 20dp and the line height should be auto, when the content of the row layout increasse the vertical line align that align left of the layout also should increase.
I tried to add line by drawing the vertical line in drawable folder and add it to the background of the layout. But the problem is line comes only as the half
Draw able : vertical_line.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:toDegrees="90"
android:pivotX="10">
<shape
android:shape="line">
<stroke
android:width="1dp"
android:color="#ff00ff"
/>
</shape>
Layout
<?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="wrap_content"
android:background="@color/black_two">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:background="@drawable/vertical_line"
>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</RelativeLayout>
Please help me to draw a line on the left of the layout with auto height
I am trying to draw vertical line in a row layout of the list (Recycler View). The line should be align left of the layout with margin left 20dp and the line height should be auto, when the content of the row layout increasse the vertical line align that align left of the layout also should increase.
I tried to add line by drawing the vertical line in drawable folder and add it to the background of the layout. But the problem is line comes only as the half
Draw able : vertical_line.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:toDegrees="90"
android:pivotX="10">
<shape
android:shape="line">
<stroke
android:width="1dp"
android:color="#ff00ff"
/>
</shape>
Layout
<?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="wrap_content"
android:background="@color/black_two">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:background="@drawable/vertical_line"
>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</RelativeLayout>
Please help me to draw a line on the left of the layout with auto height
edited Nov 30 at 8:57
Onik
11k103761
11k103761
asked Nov 22 at 4:07
Binil Surendran
76821541
76821541
Do you really a drawable xml to draw a vertical line? Because you can also do that with just views...
– Aaron
Nov 22 at 4:11
Your parentRelativeLayoutheight is "wrap_content " change it to "match_parent" so that it will draw a line on the whole screen
– Akshay Katariya
Nov 22 at 4:12
@ Aaron if we use <View> how to make that height as wrap_content
– Binil Surendran
Nov 22 at 4:16
@Akshay Katariya am using this layout as the row item of my list, so how can i change row parent layout to match_parent?. if so 1 Row consume full height of the view.
– Binil Surendran
Nov 22 at 4:17
@BinilSurendran If you use <View>, just set the height to match_parent.
– Aaron
Nov 22 at 4:18
add a comment |
Do you really a drawable xml to draw a vertical line? Because you can also do that with just views...
– Aaron
Nov 22 at 4:11
Your parentRelativeLayoutheight is "wrap_content " change it to "match_parent" so that it will draw a line on the whole screen
– Akshay Katariya
Nov 22 at 4:12
@ Aaron if we use <View> how to make that height as wrap_content
– Binil Surendran
Nov 22 at 4:16
@Akshay Katariya am using this layout as the row item of my list, so how can i change row parent layout to match_parent?. if so 1 Row consume full height of the view.
– Binil Surendran
Nov 22 at 4:17
@BinilSurendran If you use <View>, just set the height to match_parent.
– Aaron
Nov 22 at 4:18
Do you really a drawable xml to draw a vertical line? Because you can also do that with just views...
– Aaron
Nov 22 at 4:11
Do you really a drawable xml to draw a vertical line? Because you can also do that with just views...
– Aaron
Nov 22 at 4:11
Your parent
RelativeLayout height is "wrap_content " change it to "match_parent" so that it will draw a line on the whole screen– Akshay Katariya
Nov 22 at 4:12
Your parent
RelativeLayout height is "wrap_content " change it to "match_parent" so that it will draw a line on the whole screen– Akshay Katariya
Nov 22 at 4:12
@ Aaron if we use <View> how to make that height as wrap_content
– Binil Surendran
Nov 22 at 4:16
@ Aaron if we use <View> how to make that height as wrap_content
– Binil Surendran
Nov 22 at 4:16
@Akshay Katariya am using this layout as the row item of my list, so how can i change row parent layout to match_parent?. if so 1 Row consume full height of the view.
– Binil Surendran
Nov 22 at 4:17
@Akshay Katariya am using this layout as the row item of my list, so how can i change row parent layout to match_parent?. if so 1 Row consume full height of the view.
– Binil Surendran
Nov 22 at 4:17
@BinilSurendran If you use <View>, just set the height to match_parent.
– Aaron
Nov 22 at 4:18
@BinilSurendran If you use <View>, just set the height to match_parent.
– Aaron
Nov 22 at 4:18
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You can use View for vertical line instead of a shape:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:background="#ff00ff"/>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</LinearLayout>
Thanks man, I was tried same thing with the parent layout as < Relative Layout>, but as you said after change it to <Linear Layout> it is success.
– Binil Surendran
Nov 22 at 4:22
You're welcome. If you change theTextViewheight towrap_content, it will still work - theViewheight will be adjusted to match its parent, which is affected by theTextView.
– Aaron
Nov 22 at 4:26
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can use View for vertical line instead of a shape:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:background="#ff00ff"/>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</LinearLayout>
Thanks man, I was tried same thing with the parent layout as < Relative Layout>, but as you said after change it to <Linear Layout> it is success.
– Binil Surendran
Nov 22 at 4:22
You're welcome. If you change theTextViewheight towrap_content, it will still work - theViewheight will be adjusted to match its parent, which is affected by theTextView.
– Aaron
Nov 22 at 4:26
add a comment |
up vote
1
down vote
accepted
You can use View for vertical line instead of a shape:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:background="#ff00ff"/>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</LinearLayout>
Thanks man, I was tried same thing with the parent layout as < Relative Layout>, but as you said after change it to <Linear Layout> it is success.
– Binil Surendran
Nov 22 at 4:22
You're welcome. If you change theTextViewheight towrap_content, it will still work - theViewheight will be adjusted to match its parent, which is affected by theTextView.
– Aaron
Nov 22 at 4:26
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can use View for vertical line instead of a shape:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:background="#ff00ff"/>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</LinearLayout>
You can use View for vertical line instead of a shape:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:background="#ff00ff"/>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</LinearLayout>
answered Nov 22 at 4:17
Aaron
1,6131212
1,6131212
Thanks man, I was tried same thing with the parent layout as < Relative Layout>, but as you said after change it to <Linear Layout> it is success.
– Binil Surendran
Nov 22 at 4:22
You're welcome. If you change theTextViewheight towrap_content, it will still work - theViewheight will be adjusted to match its parent, which is affected by theTextView.
– Aaron
Nov 22 at 4:26
add a comment |
Thanks man, I was tried same thing with the parent layout as < Relative Layout>, but as you said after change it to <Linear Layout> it is success.
– Binil Surendran
Nov 22 at 4:22
You're welcome. If you change theTextViewheight towrap_content, it will still work - theViewheight will be adjusted to match its parent, which is affected by theTextView.
– Aaron
Nov 22 at 4:26
Thanks man, I was tried same thing with the parent layout as < Relative Layout>, but as you said after change it to <Linear Layout> it is success.
– Binil Surendran
Nov 22 at 4:22
Thanks man, I was tried same thing with the parent layout as < Relative Layout>, but as you said after change it to <Linear Layout> it is success.
– Binil Surendran
Nov 22 at 4:22
You're welcome. If you change the
TextView height to wrap_content, it will still work - the View height will be adjusted to match its parent, which is affected by the TextView.– Aaron
Nov 22 at 4:26
You're welcome. If you change the
TextView height to wrap_content, it will still work - the View height will be adjusted to match its parent, which is affected by the TextView.– Aaron
Nov 22 at 4:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423745%2fandroid-draw-vertical-line-in-a-layout%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you really a drawable xml to draw a vertical line? Because you can also do that with just views...
– Aaron
Nov 22 at 4:11
Your parent
RelativeLayoutheight is "wrap_content " change it to "match_parent" so that it will draw a line on the whole screen– Akshay Katariya
Nov 22 at 4:12
@ Aaron if we use <View> how to make that height as wrap_content
– Binil Surendran
Nov 22 at 4:16
@Akshay Katariya am using this layout as the row item of my list, so how can i change row parent layout to match_parent?. if so 1 Row consume full height of the view.
– Binil Surendran
Nov 22 at 4:17
@BinilSurendran If you use <View>, just set the height to match_parent.
– Aaron
Nov 22 at 4:18