I have an AppBarLayout
that I want to be 25% of the screen. If I was doing this without Coordinator layout
, and ConstraintLayout
I could simply use a Guideline
with 25%, however the parent layout is a Coordinator so I'm not sure what to do here. I want to do it without setting a height in DP such as 150dp
and doing it in pure XML.
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/fragprofile_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_gradient"
android:orientation="vertical">
<TextView
android:id="@+id/tv_app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="3dp"
android:fontFamily="@font/concert_one"
android:gravity="center"
android:layout_gravity="center"
android:textColor="@color/colorWhite"
android:textSize="24sp"
app:layout_constraintBottom_toTopOf="@+id/tablayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_scrollFlags="scroll|enterAlways"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:tabIndicatorColor="@color/colorWhite"
app:tabIndicatorHeight="3dp"
app:tabSelectedTextColor="@color/colorWhite"
app:tabTextColor="@color/colorWhite60PercentOpacity" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
from How do I make AppBarLayout 25% of screen whilst it's in a CoordinatorLayout?
No comments:
Post a Comment