我不明白 ImageView 大小如何在定义了权重的相对布局上工作
这是我的代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".CameraActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="76" >
<ImageView
android:id="@+id/imagePreview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/photo_placeholder" />
<Button
android:id="@+id/timeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:onClick="onClick"
android:text="Button" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="24" >
<ImageButton
android:id="@+id/mainButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#0fff"
android:src="@drawable/cam_main_btn_normal" />
<ImageButton
android:id="@+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="22dp"
android:background="#0fff"
android:src="@drawable/gs_05_check_normal" />
<ImageButton
android:id="@+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="22dp"
android:background="#0fff"
android:src="@drawable/cam_cancel" />
</RelativeLayout>
</LinearLayout>
我明白
了,但如果我删除图像,它会按照我的预期正确显示尺寸
所以问题是,我应该怎么做才能让 imageView 在相对布局的权重方面占据全部空间?
我试图将 imageView 的 android:layout_width, android:layout_height 更改为 wrap_content (没有意义,但只是检查)它不起作用。我尝试了使用和不使用 scaleType,并且不同的值不会改变。
我猜 ImageView 需要一些技巧/魔法?
-- 编辑 -- 我希望图像将在第二个屏幕截图中采用蓝色突出显示的大小:) -- 编辑 -- 我想要实现的目标: