Question

Hello I am designing one screen of my application where I require to place complete last LinearLayout to bottom of the screen, means ImageViews of that LinearLayout should be appear at the bottom end but currently they are not placing, Could you please see what could be reason for this. What it is correct way to do this

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.audiostreet.LoginActivity$PlaceholderFragment" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/logo_dans_ma_rue" />

        <com.example.customview.TextViewWithCustomFont
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/login_screen_app_tex_vertical_margin"
            android:gravity="center"
            android:text="@string/app_name"
            android:textSize="@dimen/login_screen_app_text_size" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/login_main_drawable" />

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

            <ImageView
                android:id="@+id/facebookButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/buttons_vertical_margin"
                android:adjustViewBounds="true"
                android:contentDescription="@null"
                android:src="@drawable/fb_button" />

            <ImageView
                android:id="@+id/twitterButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/buttons_vertical_margin"
                android:adjustViewBounds="true"
                android:contentDescription="@null"
                android:src="@drawable/twitter_button" />

            <ImageView
                android:id="@+id/emailButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/buttons_vertical_margin"
                android:adjustViewBounds="true"
                android:contentDescription="@null"
                android:src="@drawable/email_button" />
        </LinearLayout>
    </LinearLayout>

</ScrollView>

Currently it is looking like this and I want all three ImageViews should appear from bottom of the screen.

Tablet 7 inch

enter image description here

Tablet 10 inch

enter image description here

Was it helpful?

Solution

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.audiostreet.LoginActivity$PlaceholderFragment" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/loading" />

    <com.example.customview.TextViewWithCustomFont
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/app_name"
        android:textSize="15dp" />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/loading" />
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
    ></LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:gravity="bottom"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/facebookButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:contentDescription="@null"
            android:src="@drawable/loading" />

        <ImageView
            android:id="@+id/twitterButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:contentDescription="@null"
            android:src="@drawable/loading" />

        <ImageView
            android:id="@+id/emailButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:contentDescription="@null"
            android:src="@drawable/loading" />
    </LinearLayout>
</LinearLayout>

Do you really need ScrollView? If not than try this, otherwise scroll view will try to get minimum height of view, and my placeholder will be flattened.

Alternative is to put Buttons under ScrollView.

Last solution i see, if you really need anything in scrollView, than try to Generate your own LinearLayout and than place views on your own.

OTHER TIPS

// try this way,hope this will help you...

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.audiostreet.LoginActivity$PlaceholderFragment" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/logo_dans_ma_rue" />

        <com.example.customview.TextViewWithCustomFont
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/login_screen_app_tex_vertical_margin"
            android:gravity="center"
            android:text="@string/app_name"
            android:textSize="@dimen/login_screen_app_text_size" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/login_main_drawable" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="bottom"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/facebookButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/buttons_vertical_margin"
                android:adjustViewBounds="true"
                android:contentDescription="@null"
                android:src="@drawable/fb_button" />

            <ImageView
                android:id="@+id/twitterButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/buttons_vertical_margin"
                android:adjustViewBounds="true"
                android:contentDescription="@null"
                android:src="@drawable/twitter_button" />

            <ImageView
                android:id="@+id/emailButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/buttons_vertical_margin"
                android:adjustViewBounds="true"
                android:contentDescription="@null"
                android:src="@drawable/email_button" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top