What's the default height of a blank View?












-2















I want to separate the 4 icon with equal space like pic1.



pic1



And the XML code for pic1 is:



code1



However, at the first time, I set the Blank View height as wrap_content, then the result showed like this:



pic2.



The code for pic2 is:



code2.



The only difference is highlight by red rectangle.










share|improve this question

























  • 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
















-2















I want to separate the 4 icon with equal space like pic1.



pic1



And the XML code for pic1 is:



code1



However, at the first time, I set the Blank View height as wrap_content, then the result showed like this:



pic2.



The code for pic2 is:



code2.



The only difference is highlight by red rectangle.










share|improve this question

























  • 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














-2












-2








-2


1






I want to separate the 4 icon with equal space like pic1.



pic1



And the XML code for pic1 is:



code1



However, at the first time, I set the Blank View height as wrap_content, then the result showed like this:



pic2.



The code for pic2 is:



code2.



The only difference is highlight by red rectangle.










share|improve this question
















I want to separate the 4 icon with equal space like pic1.



pic1



And the XML code for pic1 is:



code1



However, at the first time, I set the Blank View height as wrap_content, then the result showed like this:



pic2.



The code for pic2 is:



code2.



The only difference is highlight by red rectangle.







java android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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












2 Answers
2






active

oldest

votes


















0














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 :)






share|improve this answer
























  • thanks a lot , it can achieve too.

    – LIFI
    Nov 26 '18 at 13:20



















0














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 the ConstraintLayout

  • 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.






share|improve this answer



















  • 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











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
});


}
});














draft saved

draft discarded


















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









0














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 :)






share|improve this answer
























  • thanks a lot , it can achieve too.

    – LIFI
    Nov 26 '18 at 13:20
















0














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 :)






share|improve this answer
























  • thanks a lot , it can achieve too.

    – LIFI
    Nov 26 '18 at 13:20














0












0








0







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 :)






share|improve this answer













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 :)







share|improve this answer












share|improve this answer



share|improve this answer










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



















  • 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













0














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 the ConstraintLayout

  • 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.






share|improve this answer



















  • 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
















0














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 the ConstraintLayout

  • 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.






share|improve this answer



















  • 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














0












0








0







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 the ConstraintLayout

  • 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.






share|improve this answer













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 the ConstraintLayout

  • 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.







share|improve this answer












share|improve this answer



share|improve this answer










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














  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'