Android Image View does not start from top
I have two linear layouts placed side by side. The right side layout contains an image strip. The problem is the image does not start from top, there is unwanted bottom margin appearing as well, creating unnecessary scrolling.
Best would be if there is no unnecessary scrolling at all. There are more buttons at the left side. Right side image may be clipped.
Here is my code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
android:textSize="@dimen/home_sub_caption_height" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/qutub" />
</LinearLayout>
</LinearLayout>
</ScrollView>
android android-layout layout
add a comment |
I have two linear layouts placed side by side. The right side layout contains an image strip. The problem is the image does not start from top, there is unwanted bottom margin appearing as well, creating unnecessary scrolling.
Best would be if there is no unnecessary scrolling at all. There are more buttons at the left side. Right side image may be clipped.
Here is my code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
android:textSize="@dimen/home_sub_caption_height" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/qutub" />
</LinearLayout>
</LinearLayout>
</ScrollView>
android android-layout layout
change the revelation images
– suresh madaparthi
Nov 13 '18 at 3:57
250*250 take that size
– suresh madaparthi
Nov 13 '18 at 3:58
If scrolling is not necessary, just useLinearLayout
.
– Zwal Pyae Kyaw
Nov 13 '18 at 3:59
add a comment |
I have two linear layouts placed side by side. The right side layout contains an image strip. The problem is the image does not start from top, there is unwanted bottom margin appearing as well, creating unnecessary scrolling.
Best would be if there is no unnecessary scrolling at all. There are more buttons at the left side. Right side image may be clipped.
Here is my code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
android:textSize="@dimen/home_sub_caption_height" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/qutub" />
</LinearLayout>
</LinearLayout>
</ScrollView>
android android-layout layout
I have two linear layouts placed side by side. The right side layout contains an image strip. The problem is the image does not start from top, there is unwanted bottom margin appearing as well, creating unnecessary scrolling.
Best would be if there is no unnecessary scrolling at all. There are more buttons at the left side. Right side image may be clipped.
Here is my code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
android:textSize="@dimen/home_sub_caption_height" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/qutub" />
</LinearLayout>
</LinearLayout>
</ScrollView>
android android-layout layout
android android-layout layout
asked Nov 13 '18 at 3:25
iphonem
326
326
change the revelation images
– suresh madaparthi
Nov 13 '18 at 3:57
250*250 take that size
– suresh madaparthi
Nov 13 '18 at 3:58
If scrolling is not necessary, just useLinearLayout
.
– Zwal Pyae Kyaw
Nov 13 '18 at 3:59
add a comment |
change the revelation images
– suresh madaparthi
Nov 13 '18 at 3:57
250*250 take that size
– suresh madaparthi
Nov 13 '18 at 3:58
If scrolling is not necessary, just useLinearLayout
.
– Zwal Pyae Kyaw
Nov 13 '18 at 3:59
change the revelation images
– suresh madaparthi
Nov 13 '18 at 3:57
change the revelation images
– suresh madaparthi
Nov 13 '18 at 3:57
250*250 take that size
– suresh madaparthi
Nov 13 '18 at 3:58
250*250 take that size
– suresh madaparthi
Nov 13 '18 at 3:58
If scrolling is not necessary, just use
LinearLayout
.– Zwal Pyae Kyaw
Nov 13 '18 at 3:59
If scrolling is not necessary, just use
LinearLayout
.– Zwal Pyae Kyaw
Nov 13 '18 at 3:59
add a comment |
5 Answers
5
active
oldest
votes
If you don't need scroll then remove the ScrollView
<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:scaleType="fitXY"
android:layout_height="match_parent"
android:src="@drawable/profile" />
</LinearLayout>
</LinearLayout>
add a comment |
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
/>
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_weight="1"
android:src="@drawable/profile" />
</LinearLayout>
</LinearLayout>
</ScrollView>
add a comment |
Add this attribute in ImageView
android:scaleType="fitStart"
Hope this helps!
If I do this, the image is top aligned, but bottom margin is doubled. Lots of gap below the image, lots of unnecessary scrolling.
– iphonem
Nov 15 '18 at 16:52
can you show me the sample layout in the animated version?
– Zwal Pyae Kyaw
Nov 16 '18 at 3:09
add a comment |
Try it set Imageview
layout_gravity="top"
and layout_height="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/textViewCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
android:textSize="25sp" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/qutub"
android:layout_gravity="top"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
add a comment |
in the ImageView use
android:layout_height="wrap_content"
instead of
android:layout_height="match_parent"
I guess it work.
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%2f53273342%2fandroid-image-view-does-not-start-from-top%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you don't need scroll then remove the ScrollView
<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:scaleType="fitXY"
android:layout_height="match_parent"
android:src="@drawable/profile" />
</LinearLayout>
</LinearLayout>
add a comment |
If you don't need scroll then remove the ScrollView
<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:scaleType="fitXY"
android:layout_height="match_parent"
android:src="@drawable/profile" />
</LinearLayout>
</LinearLayout>
add a comment |
If you don't need scroll then remove the ScrollView
<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:scaleType="fitXY"
android:layout_height="match_parent"
android:src="@drawable/profile" />
</LinearLayout>
</LinearLayout>
If you don't need scroll then remove the ScrollView
<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:scaleType="fitXY"
android:layout_height="match_parent"
android:src="@drawable/profile" />
</LinearLayout>
</LinearLayout>
answered Nov 13 '18 at 3:35
MJM
2,6781734
2,6781734
add a comment |
add a comment |
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
/>
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_weight="1"
android:src="@drawable/profile" />
</LinearLayout>
</LinearLayout>
</ScrollView>
add a comment |
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
/>
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_weight="1"
android:src="@drawable/profile" />
</LinearLayout>
</LinearLayout>
</ScrollView>
add a comment |
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
/>
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_weight="1"
android:src="@drawable/profile" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
/>
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_weight="1"
android:src="@drawable/profile" />
</LinearLayout>
</LinearLayout>
</ScrollView>
answered Nov 13 '18 at 4:01
suresh madaparthi
25519
25519
add a comment |
add a comment |
Add this attribute in ImageView
android:scaleType="fitStart"
Hope this helps!
If I do this, the image is top aligned, but bottom margin is doubled. Lots of gap below the image, lots of unnecessary scrolling.
– iphonem
Nov 15 '18 at 16:52
can you show me the sample layout in the animated version?
– Zwal Pyae Kyaw
Nov 16 '18 at 3:09
add a comment |
Add this attribute in ImageView
android:scaleType="fitStart"
Hope this helps!
If I do this, the image is top aligned, but bottom margin is doubled. Lots of gap below the image, lots of unnecessary scrolling.
– iphonem
Nov 15 '18 at 16:52
can you show me the sample layout in the animated version?
– Zwal Pyae Kyaw
Nov 16 '18 at 3:09
add a comment |
Add this attribute in ImageView
android:scaleType="fitStart"
Hope this helps!
Add this attribute in ImageView
android:scaleType="fitStart"
Hope this helps!
answered Nov 13 '18 at 4:10
Zwal Pyae Kyaw
878
878
If I do this, the image is top aligned, but bottom margin is doubled. Lots of gap below the image, lots of unnecessary scrolling.
– iphonem
Nov 15 '18 at 16:52
can you show me the sample layout in the animated version?
– Zwal Pyae Kyaw
Nov 16 '18 at 3:09
add a comment |
If I do this, the image is top aligned, but bottom margin is doubled. Lots of gap below the image, lots of unnecessary scrolling.
– iphonem
Nov 15 '18 at 16:52
can you show me the sample layout in the animated version?
– Zwal Pyae Kyaw
Nov 16 '18 at 3:09
If I do this, the image is top aligned, but bottom margin is doubled. Lots of gap below the image, lots of unnecessary scrolling.
– iphonem
Nov 15 '18 at 16:52
If I do this, the image is top aligned, but bottom margin is doubled. Lots of gap below the image, lots of unnecessary scrolling.
– iphonem
Nov 15 '18 at 16:52
can you show me the sample layout in the animated version?
– Zwal Pyae Kyaw
Nov 16 '18 at 3:09
can you show me the sample layout in the animated version?
– Zwal Pyae Kyaw
Nov 16 '18 at 3:09
add a comment |
Try it set Imageview
layout_gravity="top"
and layout_height="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/textViewCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
android:textSize="25sp" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/qutub"
android:layout_gravity="top"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
add a comment |
Try it set Imageview
layout_gravity="top"
and layout_height="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/textViewCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
android:textSize="25sp" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/qutub"
android:layout_gravity="top"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
add a comment |
Try it set Imageview
layout_gravity="top"
and layout_height="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/textViewCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
android:textSize="25sp" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/qutub"
android:layout_gravity="top"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
Try it set Imageview
layout_gravity="top"
and layout_height="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/textViewCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="This is my Application"
android:textSize="40sp" />
<Button
android:id="@+id/btnOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button One"
android:textSize="25sp" />
<Button
android:id="@+id/btnTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Two"
android:textSize="25sp" />
<Button
android:id="@+id/btnThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFFFF"
android:text="Button Three"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/imageViewLogo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/qutub"
android:layout_gravity="top"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
answered Nov 13 '18 at 5:17
tj2611
14312
14312
add a comment |
add a comment |
in the ImageView use
android:layout_height="wrap_content"
instead of
android:layout_height="match_parent"
I guess it work.
add a comment |
in the ImageView use
android:layout_height="wrap_content"
instead of
android:layout_height="match_parent"
I guess it work.
add a comment |
in the ImageView use
android:layout_height="wrap_content"
instead of
android:layout_height="match_parent"
I guess it work.
in the ImageView use
android:layout_height="wrap_content"
instead of
android:layout_height="match_parent"
I guess it work.
edited Nov 13 '18 at 8:24
answered Nov 13 '18 at 3:43
Avinash jain
121119
121119
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.
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%2f53273342%2fandroid-image-view-does-not-start-from-top%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
change the revelation images
– suresh madaparthi
Nov 13 '18 at 3:57
250*250 take that size
– suresh madaparthi
Nov 13 '18 at 3:58
If scrolling is not necessary, just use
LinearLayout
.– Zwal Pyae Kyaw
Nov 13 '18 at 3:59