【发布时间】:2013-09-04 17:33:18
【问题描述】:
我得到了这个布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rel2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff" >
<ImageView
android:id="@+id/tree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/lemon_large"
android:scaleType="centerCrop"
/>
<ImageView
android:id="@+id/fruit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/lemonpiece"
android:layout_alignLeft="@+id/tree"
android:layout_alignTop="@+id/tree"
android:layout_marginLeft="95dp"
android:layout_marginTop="136dp"/>
树正在被缩放,顶部和底部总是被裁剪。这是因为屏幕高度的可变性。我想做的是拥有固定的图像视图,无论它被缩放多少,它总是相对于图像视图在同一个位置。
我尝试了不同的 scaleType 值,但它实际上总是缩放图像,并且在每个屏幕上,图像都位于相对于“树”的其他位置。
我尝试的另一种可能性是将它与屏幕顶部对齐(alignParentTop、alignParentLeft、scaleType="matrix")但这不起作用,因为某些屏幕非常短,然后图片无法正确放入屏幕.换句话说,我需要保持可扩展性并锚定顶部图像。
有什么想法吗?
【问题讨论】: