Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8295499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:37:05+00:00 2026-06-08T14:37:05+00:00

My layout is below. On some mdpi screens the inner LinearLayout is cutoff. What

  • 0

My layout is below. On some mdpi screens the inner LinearLayout is cutoff. What I would like to happen is to make sure that the inner LinearLayout always shows all of it’s content. I would like the ImageView to scale down as small as it needs to make sure that the LinearLayout below it show’s all of it’s content. On large screens, the ImageView should be as large as it’s image (i.e. wrap_content).

I tried giving the ImageView a layout_weight of 0.1 and the LinearLayout a layout_weight of 0.9 (and giving both of them a layout_height of 0dp), but then on larger screens the ImageView ends up being at the top of the layout. I would like the contents of the root LinearLayout to be centered.

So is it possible to make the ImageView shrink only if it needs to, such that the LinearLayout below it is always completely visible? I am trying to accomplish this witout creating multiple layout files for different screen sizes/resolutions.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    style="@style/tab_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    tools:context=".messages.MessagesHomeFragment"
    >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="40dp"
        android:src="@drawable/elephant_large" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical"
        >

        <Button
            android:id="@+id/button_send_voice_message"
            android:layout_width="239dp"
            android:layout_height="wrap_content"
            android:text="Send a Voice Message" />

        <Button
            android:id="@+id/button_send_sms_message"
            android:layout_width="239dp"
            android:layout_height="wrap_content"
            android:text="Send an SMS" />

        <Button
            android:id="@+id/button_view_messages"
            android:layout_width="239dp"
            android:layout_height="wrap_content"
            android:text="Manage Messages" />

        <Button
            android:id="@+id/button_invite_sms_recipients"
            android:layout_width="239dp"
            android:layout_height="wrap_content"
            android:text="Invite SMS Recipients" />
    </LinearLayout>

</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:37:11+00:00Added an answer on June 8, 2026 at 2:37 pm

    I was able to accomplish what I was trying to do by using the layout below. The key was to set the root LinearLayout’s height to wrap_content and set the layout_weight of the ImageView to 1.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        style="@style/tab_fragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:orientation="vertical"
        >
    
        <ImageView
            android:id="@+id/elephantImageView"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:scaleType="fitCenter"
            android:layout_marginBottom="20dp"
            android:src="@drawable/elephant_large"
            />
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical"
            >
    
            <Button
                android:id="@+id/button_send_voice_message"
                android:layout_width="239dp"
                android:layout_height="wrap_content"
                android:text="Send a Voice Message" />
    
            ...
        </LinearLayout>
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to do some simple layout math. I remember the syntax below
I am working with layout like in below xml code <?xml version=1.0 encoding=utf-8?> <LinearLayout
Below is some code that I copied and edited. If I make the ColorsActivity
I have my layouts like below: Layout 1 : I have a LinearLayout (parent
I have a stored proc with the basic layout below that returns a sys_refcursor
Please see below: I tried using Absolute layout, but that's deprecated. I appreciate your
JSFIDDLE EXAMPLE BELOW I want to make the following CSS layout and currently im
I have a border layout whose center panel is defined like the below. {
Simple problem: With the XML layout shown below, I have some views wrapped in
I'm having some issues with this layout and having a link that displays on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.