android-layoutlayoutviewflipperflipper

how to adjust flipper size in your android studio project?


I wanted to create slideshow in my main activity page. After implementing the flipper inside my app, I notice that the FlipperLayout got overlapped with my widget Toolbar. Inside my widget toolbar contains name of the user, where I call the user full name when they are logged into the app. I'm not quite sure on how to adjust the flipper size to make sure that the slideshow will not overlap with my toolbar. And I want the flipper to be put below the toolbar. Can anyone help me ? enter image description here

 <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/frame_layout"
        android:layout_above="@id/btm_nav"
        >

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/purpleBoo"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark" >

            <TextView
                android:id="@+id/tv_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="welcome"
                android:layout_gravity="center"
                android:textColor="@color/white">

            </TextView>

        </androidx.appcompat.widget.Toolbar>


        <technolifestyle.com.imageslider.FlipperLayout
            android:id="@+id/flipper"
            android:layout_width="match_parent"
            android:layout_height="219dp">

        </technolifestyle.com.imageslider.FlipperLayout>

Solution

  • You can edit your FlipperLayout to add android:layout_marginTop="?attr/actionBarSize" attribute

     <technolifestyle.com.imageslider.FlipperLayout
                android:id="@+id/flipper"
                android:layout_width="match_parent"
                android:layout_height="219dp"
                android:layout_marginTop="?attr/actionBarSize">
    

    OR

    You can use a LinearLayout at the root of your layout instead of a FrameLayout, with android:orientation="vertical". This is because the FrameLayout is intended for purposes where child view overlapping is desired.