我有一个 FrameLayout,里面有一个垂直的 LinearLayout。我有一个 ImageView,我想将其放置在布局的最底部。我不知道该怎么做。我将其添加为 LinearLayout 中的最后一个元素,但它并未固定在底部。我怎样才能实现这个目标?
最佳答案
请发布您的布局代码。出于多种原因,我强烈建议不要使用relativelayout。通常,您的 View 中还有一些其他组件想要占用其余的空间,如果您提供该layout_weight,如另一个答案中提到的,这将解决您的问题。
例如,这将始终将您想要的内容放在底部:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<!-- fills the area -->
</ListView>
<ImageView
android:id="@+id/imageNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"/>
</LinearLayout>
关于java - 如何将 ImageView 固定到布局的底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8003130/