私のプロジェクト全体でPercentRelativeLayout
を使いたいですし、スクロールを必要としないビューでもそれを成功させることができました。ただし、ScrollView's
を使用する場合、layout_heightPercent
やlayout_marginTopPercent
などの属性は機能しません。CollapsingToolbarLayoutでPercentRelativeLayoutを使用するには?
私の問題は、具体的には私がCollapsingToolbarLayout
とNestedScrollView
を使用しているときです。私はこれが望むように動作していない理由のいくつかの手がかりを見つけましたhere。
solution(2番目の回答)は、ScrollView
を拡張してonMeasureメソッドをオーバーライドすることです。私はいくつかのビューでこれをやってみましたが、成功しませんでした。任意の助けをいただければ幸いです
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sign_in_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:fitsSystemWindows="true"
android:animateLayoutChanges="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/sign_in_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:animateLayoutChanges="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/sign_in_collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:animateLayoutChanges="true"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
app:contentScrim="@color/primaryBackground"
app:layout_scrollFlags="exitUntilCollapsed|scroll"
>
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_widthPercent="50%"
app:layout_heightPercent="80%"
app:layout_marginLeftPercent="33%"
android:scaleType="centerCrop"
android:src="@drawable/picture"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"/>
</android.support.percent.PercentRelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="58dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:animateLayoutChanges="true"
app:behavior_overlapTop="315dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_widthPercent="50%"
app:layout_heightPercent="80%"
app:layout_marginLeftPercent="33%"
android:scaleType="centerCrop"
android:src="@drawable/picture"
android:fitsSystemWindows="true" />
</android.support.percent.PercentRelativeLayout>
</android.support.v4.widget.NestedScrollView>
:
は、ここで私が働いて取得する必要がありますレイアウトです。