我有一个RelativeLayout
,里面我有一个LottieAnimationView
和另一个LinearLayout
。LottieAnimationView作为我的背景图像,在线性布局中,我有EditText
和Button
的内容。所以我的问题是,当软键盘出来时,内容应该是可滚动的,但背景图像不应该被调整大小。我已经尝试了几件事,但没有真正奏效。
我的 XML 如下所示:
<RelativeLayout>
<LottieAnimationView>
<ScrollView>
<LinearLayout>
<EditText>
<Button>
</LinearLayout>
</ScrollView>
</RelativeLayout>
我的解决方案:
我不得不把LottieAnimationView
放在LinearLayout
里,android:adjustViewBounds="true"
设置到洛蒂视图。
您还可以在布局xml中将match_parent设置为ImageView或LottieAnimationView,然后在活动/片段/视图中将其高度设置为当前:
val height = yourBackgroundImageView.height
if (height > 0) {
yourBackgroundImageView.setHeight(height)
}
只需确保在视图附加到屏幕(并测量(后完成即可。