Android Shape Line
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
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:
- Why the line is black instead white? I have tried putting it inside a ImageView but the result is the same.
- How can i set the opacity of the shape?
android shape
add a comment |
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:
- Why the line is black instead white? I have tried putting it inside a ImageView but the result is the same.
- How can i set the opacity of the shape?
android shape
add a comment |
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:
- Why the line is black instead white? I have tried putting it inside a ImageView but the result is the same.
- How can i set the opacity of the shape?
android shape
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:
- Why the line is black instead white? I have tried putting it inside a ImageView but the result is the same.
- How can i set the opacity of the shape?
android shape
android shape
edited Jul 6 '10 at 9:32
Janusz
108k103279355
108k103279355
asked May 3 '10 at 11:34
xger86xxger86x
2,930105388
2,930105388
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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.
You mean #07FFFFFF.
– Vaiden
Apr 27 '14 at 14:15
@Vaiden Android supports 4-digit ARGB. In that case, it will be interpreted as #77FFFFFF.
– Andrew T.
Sep 2 '14 at 6:10
add a comment |
The simplest example of the line for 2 density pixels with black color.
Just save the xml in drawable folder: res/drawable/shape_black_line.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#000000" />
<size android:height="2dp" />
</shape>
Use LinearLayout and background to show the line.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/divider">
</LinearLayout>
I hope this helped.
3
Wouldn't it be less memory consuming if we used<View>
instead of LinearLayout?
– Juan José Melero Gómez
Dec 17 '15 at 10:04
Yes u can use it . As everyclass is extened from view
– Hemant Shori
Dec 24 '15 at 12:37
add a comment |
A tricky way can be like this:
1) Add a View where you want have a line.
2) set android:background
to a hex value that you can set both color and opacity.
For example:
<View
android:layout_width="match_parent"
android:layout_height="6dp"
android:background="#77f27123"
android:orientation="vertical" />
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f2757707%2fandroid-shape-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
You mean #07FFFFFF.
– Vaiden
Apr 27 '14 at 14:15
@Vaiden Android supports 4-digit ARGB. In that case, it will be interpreted as #77FFFFFF.
– Andrew T.
Sep 2 '14 at 6:10
add a comment |
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.
You mean #07FFFFFF.
– Vaiden
Apr 27 '14 at 14:15
@Vaiden Android supports 4-digit ARGB. In that case, it will be interpreted as #77FFFFFF.
– Andrew T.
Sep 2 '14 at 6:10
add a comment |
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.
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.
answered May 3 '10 at 14:11
Daniel LewDaniel Lew
67.5k26167169
67.5k26167169
You mean #07FFFFFF.
– Vaiden
Apr 27 '14 at 14:15
@Vaiden Android supports 4-digit ARGB. In that case, it will be interpreted as #77FFFFFF.
– Andrew T.
Sep 2 '14 at 6:10
add a comment |
You mean #07FFFFFF.
– Vaiden
Apr 27 '14 at 14:15
@Vaiden Android supports 4-digit ARGB. In that case, it will be interpreted as #77FFFFFF.
– Andrew T.
Sep 2 '14 at 6:10
You mean #07FFFFFF.
– Vaiden
Apr 27 '14 at 14:15
You mean #07FFFFFF.
– Vaiden
Apr 27 '14 at 14:15
@Vaiden Android supports 4-digit ARGB. In that case, it will be interpreted as #77FFFFFF.
– Andrew T.
Sep 2 '14 at 6:10
@Vaiden Android supports 4-digit ARGB. In that case, it will be interpreted as #77FFFFFF.
– Andrew T.
Sep 2 '14 at 6:10
add a comment |
The simplest example of the line for 2 density pixels with black color.
Just save the xml in drawable folder: res/drawable/shape_black_line.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#000000" />
<size android:height="2dp" />
</shape>
Use LinearLayout and background to show the line.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/divider">
</LinearLayout>
I hope this helped.
3
Wouldn't it be less memory consuming if we used<View>
instead of LinearLayout?
– Juan José Melero Gómez
Dec 17 '15 at 10:04
Yes u can use it . As everyclass is extened from view
– Hemant Shori
Dec 24 '15 at 12:37
add a comment |
The simplest example of the line for 2 density pixels with black color.
Just save the xml in drawable folder: res/drawable/shape_black_line.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#000000" />
<size android:height="2dp" />
</shape>
Use LinearLayout and background to show the line.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/divider">
</LinearLayout>
I hope this helped.
3
Wouldn't it be less memory consuming if we used<View>
instead of LinearLayout?
– Juan José Melero Gómez
Dec 17 '15 at 10:04
Yes u can use it . As everyclass is extened from view
– Hemant Shori
Dec 24 '15 at 12:37
add a comment |
The simplest example of the line for 2 density pixels with black color.
Just save the xml in drawable folder: res/drawable/shape_black_line.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#000000" />
<size android:height="2dp" />
</shape>
Use LinearLayout and background to show the line.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/divider">
</LinearLayout>
I hope this helped.
The simplest example of the line for 2 density pixels with black color.
Just save the xml in drawable folder: res/drawable/shape_black_line.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#000000" />
<size android:height="2dp" />
</shape>
Use LinearLayout and background to show the line.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/divider">
</LinearLayout>
I hope this helped.
edited Dec 17 '15 at 10:51
Juan José Melero Gómez
2,32811329
2,32811329
answered Sep 2 '14 at 5:14
Hemant ShoriHemant Shori
1,9271319
1,9271319
3
Wouldn't it be less memory consuming if we used<View>
instead of LinearLayout?
– Juan José Melero Gómez
Dec 17 '15 at 10:04
Yes u can use it . As everyclass is extened from view
– Hemant Shori
Dec 24 '15 at 12:37
add a comment |
3
Wouldn't it be less memory consuming if we used<View>
instead of LinearLayout?
– Juan José Melero Gómez
Dec 17 '15 at 10:04
Yes u can use it . As everyclass is extened from view
– Hemant Shori
Dec 24 '15 at 12:37
3
3
Wouldn't it be less memory consuming if we used
<View>
instead of LinearLayout?– Juan José Melero Gómez
Dec 17 '15 at 10:04
Wouldn't it be less memory consuming if we used
<View>
instead of LinearLayout?– Juan José Melero Gómez
Dec 17 '15 at 10:04
Yes u can use it . As everyclass is extened from view
– Hemant Shori
Dec 24 '15 at 12:37
Yes u can use it . As everyclass is extened from view
– Hemant Shori
Dec 24 '15 at 12:37
add a comment |
A tricky way can be like this:
1) Add a View where you want have a line.
2) set android:background
to a hex value that you can set both color and opacity.
For example:
<View
android:layout_width="match_parent"
android:layout_height="6dp"
android:background="#77f27123"
android:orientation="vertical" />
add a comment |
A tricky way can be like this:
1) Add a View where you want have a line.
2) set android:background
to a hex value that you can set both color and opacity.
For example:
<View
android:layout_width="match_parent"
android:layout_height="6dp"
android:background="#77f27123"
android:orientation="vertical" />
add a comment |
A tricky way can be like this:
1) Add a View where you want have a line.
2) set android:background
to a hex value that you can set both color and opacity.
For example:
<View
android:layout_width="match_parent"
android:layout_height="6dp"
android:background="#77f27123"
android:orientation="vertical" />
A tricky way can be like this:
1) Add a View where you want have a line.
2) set android:background
to a hex value that you can set both color and opacity.
For example:
<View
android:layout_width="match_parent"
android:layout_height="6dp"
android:background="#77f27123"
android:orientation="vertical" />
edited Nov 24 '18 at 11:49
answered Nov 24 '18 at 7:06
Kaaveh MohamediKaaveh Mohamedi
4228
4228
add a comment |
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.
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%2f2757707%2fandroid-shape-line%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