0

I have a screen contain collapsable toolbar (AppBarLayout) and scrollable content with NestedScrollviews

My Main layout:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:theme="@style/ToolbarTheme"
        android:layout_width="match_parent"
        android:layout_height="@dimen/actionBarHeight"
        android:background="@color/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:scrollbars="none"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <FrameLayout
        android:id="@+id/layoutMainContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    </android.support.v4.widget.NestedScrollView>

    </android.support.design.widget.CoordinatorLayout>

And the layout content that I put into FrameLayout layoutMainContent is as below

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
android:background="@color/colorBackground">

<LinearLayout
    android:id="@+id/layoutAbout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_centerInParent="true">
    <ImageView
        android:id="@+id/ivLogo"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_gravity="center_horizontal"
        android:src="@drawable/logo"/>
</LinearLayout>

<TextView
    android:id="@+id/tvViewDetail"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:textColor="@color/colorPrimary"
    android:text="@string/see_license"
    android:gravity="center_horizontal"/>
</RelativeLayout>

What I want is the logo image is in the center and the TextView (tvViewDetail) is at the bottom the the screen. However, logo image is not in the center (pushed down a little bit) and tvViewDetail is pushed out of the screen.

Is there anything I've done wrong? Any suggestion would be helpful! Thank you all masters,

meaholik
  • 440
  • 5
  • 19

1 Answers1

0

Try this way I hope it helps.

<RelativeLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:background="@color/colorBackground">

         <LinearLayout
                android:id="@+id/layoutAbout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:gravity="center"
                android:layout_centerInParent="true">
                    <ImageView
                         android:id="@+id/ivLogo"
                         android:layout_width="100dp"
                         android:layout_height="100dp"
                         android:src="@drawable/logo"/>

                    <TextView
                        android:id="@+id/tvViewDetail"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/colorPrimary"
                        android:text="@string/see_license"/>
                 </LinearLayout>


              </RelativeLayout>

hence linearlayout height and width will be wrap_content and gravity will be center so all child of that linear layout will be at center of the linear layout. and linear layout also appear at the center of the relative layout.