android - 从外部布局动画视图到真实位置
问题描述
我有下一个 xml 结构:
<RelativeLayout
...>
<RelativeLayout
...
android:centerInParent=true/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="3"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:orientation="horizontal"
android:layout_weight="1">
<View
android:id="@+id/top_left"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"/>
<View
android:id="@+id/top_right"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"/>
</Linearlayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:orientation="horizontal"
android:layout_weight="1">
<View
android:id="@+id/middle_left"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"/>
<View
android:id="@+id/middle_right"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"/>
</Linearlayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:orientation="horizontal"
android:layout_weight="1">
<View
android:id="@+id/bottom_left"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"/>
<View
android:id="@+id/bottom_right"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"/>
</Linearlayout>
</Linearlayout>
</Relativelayout>
我需要像图片一样放置视图(如果视图有 4 个正方形,我需要放置在这些正方形的中间)
加载视图后,我需要将所有视图从父 RelativeLayout 中心设置为正常视图位置。
我尝试将 RelativeLayout 作为父级并为所有视图设置动画,但视图可以更改它们的大小,所以我不知道每个视图的最终位置。
反正有没有用上面写的结构来实现?
谢谢!
解决方案
我解决了这个问题,添加到所有视图的父母:
android:clipChildren="false"
android:clipToPadding="false"
推荐阅读
- flutter - Dart list.runtimeType 应该打印 _GrowableList
? - android - Android多个Handler实例监听同一个looper
- c++ - 库未加载 libpng16.16.dylib 因为版本不兼容
- java - 如何解决任务':app:kaptDebugKotlin'的执行失败。对于 kapt "androidx.room:room-compiler:$version_room
- javascript - onClick 仅在按下两次时才有效
- python - 如何在 Selenium Python 中发送像 Command C 这样的键
- c# - c# where for generic type constraint class may not be
- r - R聚合向量列表到n个向量元素的唯一组合和总和相等组合
- postgresql - 在数组 postgres 中获取最大日期 json 对象
- javascript - 在 FreeMarker 上获取 URL 的 queryString 参数的更好方法