Karuppu MGR Karuppu MGR - 3 months ago 11
Android Question

Specific Contents are not visible by using or by without using scrollview

Following is my xml layout.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#EBEBEB">

<ImageView
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:layout_height="30dp"
android:src="@drawable/contact_us"/>
<TextView
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="left"
android:text="Contact us"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000" />
</LinearLayout>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/vai" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/imageView"
android:layout_toLeftOf="@+id/imageView"
android:orientation="vertical">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Worldwide"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="48dp"
android:layout_marginStart="48dp"
android:text="Version 1.0"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>

</RelativeLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#bdb9b8">

<TextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center"
android:text="Group of Companies"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000" />
</LinearLayout>

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_marginLeft="3dp"
android:layout_height="120dp"></android.support.v4.view.ViewPager>

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#000" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#bdb9b8">

<TextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center"
android:text="Global Representativess"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000" />
</LinearLayout>

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager2"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_marginLeft="3dp"
android:layout_height="wrap_content"></android.support.v4.view.ViewPager>

<LinearLayout
android:id="@+id/last"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AgroProducts" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AgroProducts" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AgroProducts" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AgroProducts" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AgroProducts" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AgroProducts" />
</LinearLayout>


</LinearLayout>


The problem with my layout is that,


  1. The linearlayout of id
    last
    is not fully visible.

  2. I tried to encapsulate the entire layout within scrollview but if i do so , the second view pager is not getting visible. Is there any alternative to overcome this scenario?


Answer

Try to give Orientation to your Linear Layout. and Define it above your second View Pager your last Linear Layout. I have applied some changes to your Layout.

Refer this.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#EBEBEB">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:layout_marginTop="10dp"
            android:src="@mipmap/ic_launcher" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_marginTop="10dp"
            android:gravity="left"
            android:text="Contact us"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000" />
    </LinearLayout>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@mipmap/ic_launcher" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_toEndOf="@+id/imageView"
            android:layout_toLeftOf="@+id/imageView"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Worldwide"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="48dp"
                android:layout_marginStart="48dp"
                android:text="Version 1.0"
                android:textAppearance="?android:attr/textAppearanceSmall" />
        </LinearLayout>

    </RelativeLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#bdb9b8">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:gravity="center"
            android:text="Group of Companies"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000" />
    </LinearLayout>

    <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:layout_marginLeft="3dp"
        android:layout_marginTop="10dp"></android.support.v4.view.ViewPager>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#000" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#bdb9b8">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:gravity="center"
            android:text="Global Representativess"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000" />
    </LinearLayout>


    <LinearLayout
        android:id="@+id/last"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:orientation="vertical"
        android:weightSum="6">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="AgroProducts"
            android:textColor="#000000" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="AgroProducts"
            android:textColor="#000000" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="AgroProducts"
            android:textColor="#000000" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="AgroProducts"
            android:textColor="#000000" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="AgroProducts"
            android:textColor="#000000" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="AgroProducts"
            android:textColor="#000000" />
    </LinearLayout>

    <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pager2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="3dp"
        android:layout_marginTop="10dp"
        android:orientation="vertical"></android.support.v4.view.ViewPager>


</LinearLayout>