我尝试在屏幕底部设置四个按钮,并将imageView填充到其余位置。但是,我试过" 0dp" +"重量= 1"方法和在线建议的其他几种方式(不能记住我现在正在尝试的方式),但imageView仍然用整个屏幕上的按钮填充。
<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"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<ImageView
android:id="@+id/viewImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/runtime"
android:text="Rendering......"
android:singleLine="true"
android:textColor="#666666"
android:textSize="14dip"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:id="@+id/btnsLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/black">
<Button
android:id="@+id/btnSelectPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Select Photo"/>
<Button
android:id="@+id/btnSavePhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Save Photo"/>
<Button
android:id="@+id/btnLocalFilter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Local Filter"/>
<Button
android:id="@+id/btnCloudFilter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Cloud Filter"/>
</LinearLayout>
</RelativeLayout>
答案 0 :(得分:3)
在第一个android:layout_above="@+id/btnsLayout"
中设置LinearLayout
:
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:layout_above="@+id/btnsLayout">
...
</LinearLayout>
答案 1 :(得分:1)
实现这一目标的一种方法是遵循;
<RelativeLayout
.... >
<LinearLayout
android:id="@+id/btnsLayout"
... >
...button elements
</LinearLayout>
<LinearLayout
...
android:layout_above="@id/btnsLayout"
...>
...image view etc
</LinearLayout>
</RelativeLayout>
这样你就可以告诉最外面的RelativeLayout布局包含ImageView的LinearLayout,上面的按钮包含LinearLayout。