使用“相对布局百分比”库将对象置于屏幕之外



我想使用 PercentLayoutLibrary 将对象放置在屏幕底部之外,以便只有在向下滚动时才能看到它。我尝试了以下代码,但它不起作用 - 图像不在屏幕上,我无法向下滚动以查看它。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/ScrollView01"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">
    <android.support.percent.PercentRelativeLayout
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_widthPercent="5%"
                app:layout_heightPercent="8%"
                app:layout_marginTopPercent="105%"
                app:layout_marginLeftPercent="25%"
                android:scaleType="fitXY"
                android:id="@+id/bottom"/>
    </android.support.percent.PercentRelativeLayout>
</ScrollView>

PercentRelativeLayout 中的百分比是相对于父级的,而不是相对于屏幕的。

我认为这种方法不会带来成功,但我想不出一个简单的替代方案。

干净的方法是实现PercentScrollView,但这可能并不容易。

最新更新