我只是在浪费时间,因为我不知道如何正确地做到这一点。基本上,我想有一个自定义输入视图,用户可以用他/她的手指绘制他想要的任何内容,并且在其下面,我想放置2个(或更多)按钮,这些按钮我不想重叠自定义视图的顶部。因为我试图避免硬编码的宽度和高度,有没有什么办法来指定按钮应该包装到他们的内容和自定义视图应该占据剩余的高度?因为我希望所有按钮具有相同的高度,我想,他们取了一个高度为基准应该以某种方式工作...对齐控件
这是我目前的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<com.example.myapp.DrawView
android:id="@+id/drawView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<Button
android:id="@+id/buttonSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="@string/save" />
<Button
android:id="@+id/buttonQuery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="@string/query" />
</RelativeLayout>
它实际上是可能的实现我想要的东西,而不必以恶意的方式破解它?
很酷的家伙,说没有的伎俩!如果可以的话,我会给你一个+10的! :) – 2012-07-31 13:09:19
如果你想避免在DrawView @Mihai Todor之前声明Button,你可以在'res/values/ids.xml'文件中声明这些id。这样,你声明按钮/绘制视图的顺序根本就不重要。该ID已经在布局文件的外部存在。 – scriptocalypse 2013-11-13 19:01:25