LinearLayout won't fill screen
Having a few issues with getting my linear layout to fill the screen when testing on a tablet. On a phone it works fine but this is what happens on a tablet:
Here is the xml code, I have looked at suggestions for scroll view, etc but nothing has worked so far!
<?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"
android:weightSum="100">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:id="@+id/tvOrderNumber"
android:layout_width="match_parent"
android:layout_height="45dp"
android:gravity="center"
android:text=""
android:textAlignment="center" />
<TextView
android:id="@+id/tvDateTime"
android:layout_width="match_parent"
android:layout_height="45dp"
android:text=""
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:id="@+id/tvItemType"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:text=""
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:gravity="center"
android:text="Name"
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="@+id/tvItemName"
android:layout_below="@+id/textView2"/>
<TextView
android:gravity="center"
android:text="Qty"
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="@+id/tvItemQty"
android:layout_below="@+id/textView2"/>
</LinearLayout>
</LinearLayout>
And this is how AndroidStudio says it will display on a 10.1" tablet
android android-layout
add a comment |
Having a few issues with getting my linear layout to fill the screen when testing on a tablet. On a phone it works fine but this is what happens on a tablet:
Here is the xml code, I have looked at suggestions for scroll view, etc but nothing has worked so far!
<?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"
android:weightSum="100">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:id="@+id/tvOrderNumber"
android:layout_width="match_parent"
android:layout_height="45dp"
android:gravity="center"
android:text=""
android:textAlignment="center" />
<TextView
android:id="@+id/tvDateTime"
android:layout_width="match_parent"
android:layout_height="45dp"
android:text=""
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:id="@+id/tvItemType"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:text=""
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:gravity="center"
android:text="Name"
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="@+id/tvItemName"
android:layout_below="@+id/textView2"/>
<TextView
android:gravity="center"
android:text="Qty"
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="@+id/tvItemQty"
android:layout_below="@+id/textView2"/>
</LinearLayout>
</LinearLayout>
And this is how AndroidStudio says it will display on a 10.1" tablet
android android-layout
It looks like the layout you posted (with the three linearlayouts inside a horizontal linearlayout) must be included in some other layout. Perhaps you're using it as the layout for item views in a recyclerview? Please post the root layout (the one with the recyclerview, if I've guessed correctly).
– Ben P.
Aug 15 '18 at 20:31
Thanks Ben, as soon as you mentioned that I was able to figure the rest out! Still very new to android and have about 101 other issues I can't solve but you have successfully solved one for me, I really appreciate it!
– androidUser1993
Aug 15 '18 at 20:42
For what it's worth, it would be nice to write up an answer to your own question explaining what you realized and how you fixed it, in case someone else has a similar problem in the future. And then you don't have to edit the question title to say "SOLVED" because the question will have an accepted answer.
– Ben P.
Aug 15 '18 at 21:03
I'll do that now Ben, thanks for the advice.. as you can tell I'm pretty new to this sort of thing!
– androidUser1993
Aug 15 '18 at 21:16
Possible duplicate of What does android:layout_weight mean?
– Martin Zeitler
Jan 1 at 15:57
add a comment |
Having a few issues with getting my linear layout to fill the screen when testing on a tablet. On a phone it works fine but this is what happens on a tablet:
Here is the xml code, I have looked at suggestions for scroll view, etc but nothing has worked so far!
<?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"
android:weightSum="100">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:id="@+id/tvOrderNumber"
android:layout_width="match_parent"
android:layout_height="45dp"
android:gravity="center"
android:text=""
android:textAlignment="center" />
<TextView
android:id="@+id/tvDateTime"
android:layout_width="match_parent"
android:layout_height="45dp"
android:text=""
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:id="@+id/tvItemType"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:text=""
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:gravity="center"
android:text="Name"
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="@+id/tvItemName"
android:layout_below="@+id/textView2"/>
<TextView
android:gravity="center"
android:text="Qty"
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="@+id/tvItemQty"
android:layout_below="@+id/textView2"/>
</LinearLayout>
</LinearLayout>
And this is how AndroidStudio says it will display on a 10.1" tablet
android android-layout
Having a few issues with getting my linear layout to fill the screen when testing on a tablet. On a phone it works fine but this is what happens on a tablet:
Here is the xml code, I have looked at suggestions for scroll view, etc but nothing has worked so far!
<?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"
android:weightSum="100">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:id="@+id/tvOrderNumber"
android:layout_width="match_parent"
android:layout_height="45dp"
android:gravity="center"
android:text=""
android:textAlignment="center" />
<TextView
android:id="@+id/tvDateTime"
android:layout_width="match_parent"
android:layout_height="45dp"
android:text=""
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:id="@+id/tvItemType"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:text=""
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="33.3">
<TextView
android:gravity="center"
android:text="Name"
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="@+id/tvItemName"
android:layout_below="@+id/textView2"/>
<TextView
android:gravity="center"
android:text="Qty"
android:layout_width="match_parent"
android:layout_height="45dp"
android:id="@+id/tvItemQty"
android:layout_below="@+id/textView2"/>
</LinearLayout>
</LinearLayout>
And this is how AndroidStudio says it will display on a 10.1" tablet
android android-layout
android android-layout
edited Jan 1 at 15:37
Cœur
18.4k9109148
18.4k9109148
asked Aug 15 '18 at 20:23
androidUser1993androidUser1993
588
588
It looks like the layout you posted (with the three linearlayouts inside a horizontal linearlayout) must be included in some other layout. Perhaps you're using it as the layout for item views in a recyclerview? Please post the root layout (the one with the recyclerview, if I've guessed correctly).
– Ben P.
Aug 15 '18 at 20:31
Thanks Ben, as soon as you mentioned that I was able to figure the rest out! Still very new to android and have about 101 other issues I can't solve but you have successfully solved one for me, I really appreciate it!
– androidUser1993
Aug 15 '18 at 20:42
For what it's worth, it would be nice to write up an answer to your own question explaining what you realized and how you fixed it, in case someone else has a similar problem in the future. And then you don't have to edit the question title to say "SOLVED" because the question will have an accepted answer.
– Ben P.
Aug 15 '18 at 21:03
I'll do that now Ben, thanks for the advice.. as you can tell I'm pretty new to this sort of thing!
– androidUser1993
Aug 15 '18 at 21:16
Possible duplicate of What does android:layout_weight mean?
– Martin Zeitler
Jan 1 at 15:57
add a comment |
It looks like the layout you posted (with the three linearlayouts inside a horizontal linearlayout) must be included in some other layout. Perhaps you're using it as the layout for item views in a recyclerview? Please post the root layout (the one with the recyclerview, if I've guessed correctly).
– Ben P.
Aug 15 '18 at 20:31
Thanks Ben, as soon as you mentioned that I was able to figure the rest out! Still very new to android and have about 101 other issues I can't solve but you have successfully solved one for me, I really appreciate it!
– androidUser1993
Aug 15 '18 at 20:42
For what it's worth, it would be nice to write up an answer to your own question explaining what you realized and how you fixed it, in case someone else has a similar problem in the future. And then you don't have to edit the question title to say "SOLVED" because the question will have an accepted answer.
– Ben P.
Aug 15 '18 at 21:03
I'll do that now Ben, thanks for the advice.. as you can tell I'm pretty new to this sort of thing!
– androidUser1993
Aug 15 '18 at 21:16
Possible duplicate of What does android:layout_weight mean?
– Martin Zeitler
Jan 1 at 15:57
It looks like the layout you posted (with the three linearlayouts inside a horizontal linearlayout) must be included in some other layout. Perhaps you're using it as the layout for item views in a recyclerview? Please post the root layout (the one with the recyclerview, if I've guessed correctly).
– Ben P.
Aug 15 '18 at 20:31
It looks like the layout you posted (with the three linearlayouts inside a horizontal linearlayout) must be included in some other layout. Perhaps you're using it as the layout for item views in a recyclerview? Please post the root layout (the one with the recyclerview, if I've guessed correctly).
– Ben P.
Aug 15 '18 at 20:31
Thanks Ben, as soon as you mentioned that I was able to figure the rest out! Still very new to android and have about 101 other issues I can't solve but you have successfully solved one for me, I really appreciate it!
– androidUser1993
Aug 15 '18 at 20:42
Thanks Ben, as soon as you mentioned that I was able to figure the rest out! Still very new to android and have about 101 other issues I can't solve but you have successfully solved one for me, I really appreciate it!
– androidUser1993
Aug 15 '18 at 20:42
For what it's worth, it would be nice to write up an answer to your own question explaining what you realized and how you fixed it, in case someone else has a similar problem in the future. And then you don't have to edit the question title to say "SOLVED" because the question will have an accepted answer.
– Ben P.
Aug 15 '18 at 21:03
For what it's worth, it would be nice to write up an answer to your own question explaining what you realized and how you fixed it, in case someone else has a similar problem in the future. And then you don't have to edit the question title to say "SOLVED" because the question will have an accepted answer.
– Ben P.
Aug 15 '18 at 21:03
I'll do that now Ben, thanks for the advice.. as you can tell I'm pretty new to this sort of thing!
– androidUser1993
Aug 15 '18 at 21:16
I'll do that now Ben, thanks for the advice.. as you can tell I'm pretty new to this sort of thing!
– androidUser1993
Aug 15 '18 at 21:16
Possible duplicate of What does android:layout_weight mean?
– Martin Zeitler
Jan 1 at 15:57
Possible duplicate of What does android:layout_weight mean?
– Martin Zeitler
Jan 1 at 15:57
add a comment |
2 Answers
2
active
oldest
votes
I cannot reproduce your error on an emulator.
Try make the inner layouts android:layout_width="0dp"
and android:layout_weight="1"
, and remove android:weightSum="100"
.
add a comment |
You have to add landscape orientation for your app in resources and redesign layout for horizontal layout. Here is the guide
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%2f51865894%2flinearlayout-wont-fill-screen%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
I cannot reproduce your error on an emulator.
Try make the inner layouts android:layout_width="0dp"
and android:layout_weight="1"
, and remove android:weightSum="100"
.
add a comment |
I cannot reproduce your error on an emulator.
Try make the inner layouts android:layout_width="0dp"
and android:layout_weight="1"
, and remove android:weightSum="100"
.
add a comment |
I cannot reproduce your error on an emulator.
Try make the inner layouts android:layout_width="0dp"
and android:layout_weight="1"
, and remove android:weightSum="100"
.
I cannot reproduce your error on an emulator.
Try make the inner layouts android:layout_width="0dp"
and android:layout_weight="1"
, and remove android:weightSum="100"
.
answered Aug 15 '18 at 20:33
Xi WeiXi Wei
8921322
8921322
add a comment |
add a comment |
You have to add landscape orientation for your app in resources and redesign layout for horizontal layout. Here is the guide
add a comment |
You have to add landscape orientation for your app in resources and redesign layout for horizontal layout. Here is the guide
add a comment |
You have to add landscape orientation for your app in resources and redesign layout for horizontal layout. Here is the guide
You have to add landscape orientation for your app in resources and redesign layout for horizontal layout. Here is the guide
answered Aug 15 '18 at 20:43
JAGUARJAGUAR
116
116
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%2f51865894%2flinearlayout-wont-fill-screen%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
It looks like the layout you posted (with the three linearlayouts inside a horizontal linearlayout) must be included in some other layout. Perhaps you're using it as the layout for item views in a recyclerview? Please post the root layout (the one with the recyclerview, if I've guessed correctly).
– Ben P.
Aug 15 '18 at 20:31
Thanks Ben, as soon as you mentioned that I was able to figure the rest out! Still very new to android and have about 101 other issues I can't solve but you have successfully solved one for me, I really appreciate it!
– androidUser1993
Aug 15 '18 at 20:42
For what it's worth, it would be nice to write up an answer to your own question explaining what you realized and how you fixed it, in case someone else has a similar problem in the future. And then you don't have to edit the question title to say "SOLVED" because the question will have an accepted answer.
– Ben P.
Aug 15 '18 at 21:03
I'll do that now Ben, thanks for the advice.. as you can tell I'm pretty new to this sort of thing!
– androidUser1993
Aug 15 '18 at 21:16
Possible duplicate of What does android:layout_weight mean?
– Martin Zeitler
Jan 1 at 15:57