【发布时间】:2020-05-11 10:42:01
【问题描述】:
我想要分层图像,如下所示。
目前,我是这样做的
layout.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"
android:gravity="center">
<View
android:id="@+id/view1"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="10dp"
android:background="@drawable/images1">
</View>
<View
android:id="@+id/view2"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:background="@drawable/images1">
</View>
<View
android:id="@+id/view3"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:background="@drawable/images1">
</View>
</RelativeLayout>
但我觉得这种使用 XML 的手动方法可能会根据不同的设备和屏幕类型而有所不同和反应。那么,我怎样才能以更好或最好的方式实现它呢?如何让它动态化?
谢谢。
【问题讨论】:
标签: android view imageview android-custom-view layered