Android Image View does not start from top












0














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>


This is my app's screenshot










share|improve this question






















  • 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
















0














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>


This is my app's screenshot










share|improve this question






















  • 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














0












0








0







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>


This is my app's screenshot










share|improve this question













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>


This is my app's screenshot







android android-layout layout






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 use LinearLayout.
    – Zwal Pyae Kyaw
    Nov 13 '18 at 3:59


















  • 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
















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












5 Answers
5






active

oldest

votes


















0














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>





share|improve this answer





























    0














    <?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>





    share|improve this answer





























      0














      Add this attribute in ImageView




      android:scaleType="fitStart"




      Hope this helps!






      share|improve this answer





















      • 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



















      0














      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>





      share|improve this answer





























        0














        in the ImageView use
        android:layout_height="wrap_content"



        instead of
        android:layout_height="match_parent"



        I guess it work.






        share|improve this answer























          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%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









          0














          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>





          share|improve this answer


























            0














            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>





            share|improve this answer
























              0












              0








              0






              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>





              share|improve this answer












              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>






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 13 '18 at 3:35









              MJM

              2,6781734




              2,6781734

























                  0














                  <?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>





                  share|improve this answer


























                    0














                    <?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>





                    share|improve this answer
























                      0












                      0








                      0






                      <?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>





                      share|improve this answer












                      <?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>






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Nov 13 '18 at 4:01









                      suresh madaparthi

                      25519




                      25519























                          0














                          Add this attribute in ImageView




                          android:scaleType="fitStart"




                          Hope this helps!






                          share|improve this answer





















                          • 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
















                          0














                          Add this attribute in ImageView




                          android:scaleType="fitStart"




                          Hope this helps!






                          share|improve this answer





















                          • 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














                          0












                          0








                          0






                          Add this attribute in ImageView




                          android:scaleType="fitStart"




                          Hope this helps!






                          share|improve this answer












                          Add this attribute in ImageView




                          android:scaleType="fitStart"




                          Hope this helps!







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          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


















                          • 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











                          0














                          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>





                          share|improve this answer


























                            0














                            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>





                            share|improve this answer
























                              0












                              0








                              0






                              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>





                              share|improve this answer












                              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>






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 13 '18 at 5:17









                              tj2611

                              14312




                              14312























                                  0














                                  in the ImageView use
                                  android:layout_height="wrap_content"



                                  instead of
                                  android:layout_height="match_parent"



                                  I guess it work.






                                  share|improve this answer




























                                    0














                                    in the ImageView use
                                    android:layout_height="wrap_content"



                                    instead of
                                    android:layout_height="match_parent"



                                    I guess it work.






                                    share|improve this answer


























                                      0












                                      0








                                      0






                                      in the ImageView use
                                      android:layout_height="wrap_content"



                                      instead of
                                      android:layout_height="match_parent"



                                      I guess it work.






                                      share|improve this answer














                                      in the ImageView use
                                      android:layout_height="wrap_content"



                                      instead of
                                      android:layout_height="match_parent"



                                      I guess it work.







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Nov 13 '18 at 8:24

























                                      answered Nov 13 '18 at 3:43









                                      Avinash jain

                                      121119




                                      121119






























                                          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.





                                          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.




                                          draft saved


                                          draft discarded














                                          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





















































                                          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

                                          Xamarin.iOS Cant Deploy on Iphone

                                          Glorious Revolution

                                          Dulmage-Mendelsohn matrix decomposition in Python