android - "Shrink" CardView while scrolling in another view
问题描述
Screenshot
As you can see, the layout is a bit too big for the older device. My idea is to shrink the CardView while the user is scrolling in the white area (ViewPager) to make it bigger. I have seen it working well in another app (can't remember which). I have no idea how I can do it, do I need write it programmatically?
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".WordActivity">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="20dp"
android:visibility="gone" />
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="0dp"
app:cardBackgroundColor="@color/primary_dark"
app:cardCornerRadius="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<TextView
android:id="@+id/wordTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/poweredBy"
android:layout_centerInParent="true"
android:layout_marginTop="-12dp"
android:fontFamily="@font/poppins"
android:text="@string/word_title"
android:textColor="@android:color/white"
android:textSize="30sp" />
<TextView
android:id="@+id/wordTranslated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/wordTitle"
android:layout_alignStart="@id/wordTitle"
android:layout_marginTop="-10dp"
android:fontFamily="@font/poppins"
android:textColor="@android:color/darker_gray"
android:textSize="16sp" />
<TextView
android:id="@+id/poweredBy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:fontFamily="@font/bungee_hairline"
android:text="@string/powered"
android:textColor="@android:color/darker_gray"
android:textSize="16sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/cardView">
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/primary"
android:elevation="5dp"
app:tabIndicatorColor="@android:color/white"
app:tabIndicatorHeight="2dp"
app:tabPaddingEnd="-1dp"
app:tabPaddingStart="-1dp"
app:tabSelectedTextColor="@android:color/white"
app:tabTextColor="@color/white_transparent" />
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp" />
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
解决方案
推荐阅读
- algorithm - 匹配来自两个列表的大量坐标
- neo4j - 如何在不改变数据的情况下在 neo4j 中显示(图形)传递关系
- javascript - 使用 auth0 时,我无法访问范围 read:current_user
- c# - ASP.Net Core MVC 路由问题
- c# - 在 System.IdentityModel 中使用符合 Fips 的哈希算法验证令牌
- apache-flink - Apache Flink:DataStream API 中的侧输出和 split() 有什么区别?
- google-analytics - 如何在 React Ga 中添加自定义维度?
- python - 无法允许可能不是警报的通知
- java - Sun MonitoredHost 类的 Java 10 替代品
- javascript - _.sumBy 数组中相同键的总计