What's the default height of a blank View?
I want to separate the 4 icon with equal space like pic1
.
And the XML code for pic1
is:
However, at the first time, I set the Blank View height as wrap_content
, then the result showed like this:
.
The code for pic2
is:
.
The only difference is highlight by red rectangle.
java android
add a comment |
I want to separate the 4 icon with equal space like pic1
.
And the XML code for pic1
is:
However, at the first time, I set the Blank View height as wrap_content
, then the result showed like this:
.
The code for pic2
is:
.
The only difference is highlight by red rectangle.
java android
Please consider including code snippets directly, not via links, it is much harder to open all the links and compare the code. Thanks
– Urosh T.
Nov 24 '18 at 20:39
add a comment |
I want to separate the 4 icon with equal space like pic1
.
And the XML code for pic1
is:
However, at the first time, I set the Blank View height as wrap_content
, then the result showed like this:
.
The code for pic2
is:
.
The only difference is highlight by red rectangle.
java android
I want to separate the 4 icon with equal space like pic1
.
And the XML code for pic1
is:
However, at the first time, I set the Blank View height as wrap_content
, then the result showed like this:
.
The code for pic2
is:
.
The only difference is highlight by red rectangle.
java android
java android
edited Nov 25 '18 at 14:47
kit
1,1063816
1,1063816
asked Nov 24 '18 at 18:09
LIFILIFI
4
4
Please consider including code snippets directly, not via links, it is much harder to open all the links and compare the code. Thanks
– Urosh T.
Nov 24 '18 at 20:39
add a comment |
Please consider including code snippets directly, not via links, it is much harder to open all the links and compare the code. Thanks
– Urosh T.
Nov 24 '18 at 20:39
Please consider including code snippets directly, not via links, it is much harder to open all the links and compare the code. Thanks
– Urosh T.
Nov 24 '18 at 20:39
Please consider including code snippets directly, not via links, it is much harder to open all the links and compare the code. Thanks
– Urosh T.
Nov 24 '18 at 20:39
add a comment |
2 Answers
2
active
oldest
votes
use this code in place of that linearlayout containing all the icons
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your first icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your second icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your third icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your fourth icon code here-->
</LinearLayout>
hope that helps
if some problem leme know
happy coding :)
thanks a lot , it can achieve too.
– LIFI
Nov 26 '18 at 13:20
add a comment |
In the case of this layout, you will get more from a ConstraintLayout
.
Specifically, setting your icons within a ConstraintLayout
would look like this to get the balanced look you're going for:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/image_2"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
<ImageView
android:id="@+id/image_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_1"
app:layout_constraintEnd_toStartOf="@id/image_3"
app:layout_constraintHorizontal_chainStyle="spread_inside" />
<ImageView
android:id="@+id/image_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_2"
app:layout_constraintEnd_toStartOf="@id/image_4"
app:layout_constraintHorizontal_chainStyle="spread_inside" />
<ImageView
android:id="@+id/image_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
</androidx.constraintlayout.widget.ConstraintLayout>
The takeaways from this snippet that get your look are:
horizontal
Orientation for theConstraintLayout
- Constraints for each
ImageView
that attach them to the one before and after - First view is constraint to the
parent
, specially, as is the last view
app:layout_constraintHorizontal_chainStyle="spread_inside"
, says to spread them out evenly within the available space.
If you don't want them touching the sides, add padding to the left/right of the parent ConstraintLayout
.
1
I will try ConstraintLayout next time, thanks for your suggestion!
– LIFI
Nov 26 '18 at 13:21
Yep! In that case, you can accept this answer!
– gtcompscientist
Nov 26 '18 at 20:54
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%2f53461026%2fwhats-the-default-height-of-a-blank-view%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
use this code in place of that linearlayout containing all the icons
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your first icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your second icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your third icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your fourth icon code here-->
</LinearLayout>
hope that helps
if some problem leme know
happy coding :)
thanks a lot , it can achieve too.
– LIFI
Nov 26 '18 at 13:20
add a comment |
use this code in place of that linearlayout containing all the icons
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your first icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your second icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your third icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your fourth icon code here-->
</LinearLayout>
hope that helps
if some problem leme know
happy coding :)
thanks a lot , it can achieve too.
– LIFI
Nov 26 '18 at 13:20
add a comment |
use this code in place of that linearlayout containing all the icons
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your first icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your second icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your third icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your fourth icon code here-->
</LinearLayout>
hope that helps
if some problem leme know
happy coding :)
use this code in place of that linearlayout containing all the icons
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your first icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your second icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your third icon code here-->
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<!--keep your fourth icon code here-->
</LinearLayout>
hope that helps
if some problem leme know
happy coding :)
answered Nov 25 '18 at 0:21
Har KalHar Kal
612414
612414
thanks a lot , it can achieve too.
– LIFI
Nov 26 '18 at 13:20
add a comment |
thanks a lot , it can achieve too.
– LIFI
Nov 26 '18 at 13:20
thanks a lot , it can achieve too.
– LIFI
Nov 26 '18 at 13:20
thanks a lot , it can achieve too.
– LIFI
Nov 26 '18 at 13:20
add a comment |
In the case of this layout, you will get more from a ConstraintLayout
.
Specifically, setting your icons within a ConstraintLayout
would look like this to get the balanced look you're going for:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/image_2"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
<ImageView
android:id="@+id/image_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_1"
app:layout_constraintEnd_toStartOf="@id/image_3"
app:layout_constraintHorizontal_chainStyle="spread_inside" />
<ImageView
android:id="@+id/image_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_2"
app:layout_constraintEnd_toStartOf="@id/image_4"
app:layout_constraintHorizontal_chainStyle="spread_inside" />
<ImageView
android:id="@+id/image_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
</androidx.constraintlayout.widget.ConstraintLayout>
The takeaways from this snippet that get your look are:
horizontal
Orientation for theConstraintLayout
- Constraints for each
ImageView
that attach them to the one before and after - First view is constraint to the
parent
, specially, as is the last view
app:layout_constraintHorizontal_chainStyle="spread_inside"
, says to spread them out evenly within the available space.
If you don't want them touching the sides, add padding to the left/right of the parent ConstraintLayout
.
1
I will try ConstraintLayout next time, thanks for your suggestion!
– LIFI
Nov 26 '18 at 13:21
Yep! In that case, you can accept this answer!
– gtcompscientist
Nov 26 '18 at 20:54
add a comment |
In the case of this layout, you will get more from a ConstraintLayout
.
Specifically, setting your icons within a ConstraintLayout
would look like this to get the balanced look you're going for:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/image_2"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
<ImageView
android:id="@+id/image_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_1"
app:layout_constraintEnd_toStartOf="@id/image_3"
app:layout_constraintHorizontal_chainStyle="spread_inside" />
<ImageView
android:id="@+id/image_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_2"
app:layout_constraintEnd_toStartOf="@id/image_4"
app:layout_constraintHorizontal_chainStyle="spread_inside" />
<ImageView
android:id="@+id/image_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
</androidx.constraintlayout.widget.ConstraintLayout>
The takeaways from this snippet that get your look are:
horizontal
Orientation for theConstraintLayout
- Constraints for each
ImageView
that attach them to the one before and after - First view is constraint to the
parent
, specially, as is the last view
app:layout_constraintHorizontal_chainStyle="spread_inside"
, says to spread them out evenly within the available space.
If you don't want them touching the sides, add padding to the left/right of the parent ConstraintLayout
.
1
I will try ConstraintLayout next time, thanks for your suggestion!
– LIFI
Nov 26 '18 at 13:21
Yep! In that case, you can accept this answer!
– gtcompscientist
Nov 26 '18 at 20:54
add a comment |
In the case of this layout, you will get more from a ConstraintLayout
.
Specifically, setting your icons within a ConstraintLayout
would look like this to get the balanced look you're going for:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/image_2"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
<ImageView
android:id="@+id/image_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_1"
app:layout_constraintEnd_toStartOf="@id/image_3"
app:layout_constraintHorizontal_chainStyle="spread_inside" />
<ImageView
android:id="@+id/image_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_2"
app:layout_constraintEnd_toStartOf="@id/image_4"
app:layout_constraintHorizontal_chainStyle="spread_inside" />
<ImageView
android:id="@+id/image_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
</androidx.constraintlayout.widget.ConstraintLayout>
The takeaways from this snippet that get your look are:
horizontal
Orientation for theConstraintLayout
- Constraints for each
ImageView
that attach them to the one before and after - First view is constraint to the
parent
, specially, as is the last view
app:layout_constraintHorizontal_chainStyle="spread_inside"
, says to spread them out evenly within the available space.
If you don't want them touching the sides, add padding to the left/right of the parent ConstraintLayout
.
In the case of this layout, you will get more from a ConstraintLayout
.
Specifically, setting your icons within a ConstraintLayout
would look like this to get the balanced look you're going for:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/image_2"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
<ImageView
android:id="@+id/image_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_1"
app:layout_constraintEnd_toStartOf="@id/image_3"
app:layout_constraintHorizontal_chainStyle="spread_inside" />
<ImageView
android:id="@+id/image_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_2"
app:layout_constraintEnd_toStartOf="@id/image_4"
app:layout_constraintHorizontal_chainStyle="spread_inside" />
<ImageView
android:id="@+id/image_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/check"
app:layout_constraintStart_toEndOf="@id/image_3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread_inside"/>
</androidx.constraintlayout.widget.ConstraintLayout>
The takeaways from this snippet that get your look are:
horizontal
Orientation for theConstraintLayout
- Constraints for each
ImageView
that attach them to the one before and after - First view is constraint to the
parent
, specially, as is the last view
app:layout_constraintHorizontal_chainStyle="spread_inside"
, says to spread them out evenly within the available space.
If you don't want them touching the sides, add padding to the left/right of the parent ConstraintLayout
.
answered Nov 25 '18 at 0:42
gtcompscientistgtcompscientist
613516
613516
1
I will try ConstraintLayout next time, thanks for your suggestion!
– LIFI
Nov 26 '18 at 13:21
Yep! In that case, you can accept this answer!
– gtcompscientist
Nov 26 '18 at 20:54
add a comment |
1
I will try ConstraintLayout next time, thanks for your suggestion!
– LIFI
Nov 26 '18 at 13:21
Yep! In that case, you can accept this answer!
– gtcompscientist
Nov 26 '18 at 20:54
1
1
I will try ConstraintLayout next time, thanks for your suggestion!
– LIFI
Nov 26 '18 at 13:21
I will try ConstraintLayout next time, thanks for your suggestion!
– LIFI
Nov 26 '18 at 13:21
Yep! In that case, you can accept this answer!
– gtcompscientist
Nov 26 '18 at 20:54
Yep! In that case, you can accept this answer!
– gtcompscientist
Nov 26 '18 at 20:54
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%2f53461026%2fwhats-the-default-height-of-a-blank-view%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
Please consider including code snippets directly, not via links, it is much harder to open all the links and compare the code. Thanks
– Urosh T.
Nov 24 '18 at 20:39