我的 Activity 有一个布局,这个布局包含很多小部件。 在我从 Listview 中的 web 服务加载的 Activity 数据中。 当 ListView 被改编并填充所有数据时。 imagview 是隐形的 但是我想在加载数据时在 Listview 下方显示 Imageview。
我在 activity_main.xml 中的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rel_index"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f8f8"
tools:context=".MainActivity" >
<EditText
android:id="@+id/edt_search"
android:layout_width="fill_parent"
android:layout_height="40sp"
android:layout_marginLeft="10sp"
android:layout_marginRight="10sp"
android:layout_marginTop="115sp"
android:background="@drawable/round_corener_edittext"
android:drawableLeft="@drawable/center"
android:hint="@string/search"
android:paddingLeft="5sp"
android:paddingRight="5sp"
android:textColor="#44e1f4" />
<RelativeLayout
android:id="@+id/rel_top"
android:layout_width="fill_parent"
android:layout_height="135sp"
android:layout_marginBottom="25sp"
android:background="@drawable/header" >
<ImageView
android:id="@+id/img_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="10sp"
android:background="@drawable/digi_logo"
android:visibility="gone" />
<View
android:id="@+id/line"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_below="@+id/img_logo"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20sp"
android:layout_marginRight="20sp"
android:background="#2391a2"
android:visibility="gone" />
<TextView
android:id="@+id/txt_app"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/line"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10sp"
android:layout_marginTop="5sp"
android:text="@string/txt_name"
android:textColor="#1e7c95"
android:textSize="14sp"
android:visibility="gone" />
</RelativeLayout>
<ListView
android:id="@+id/lst_data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rel_top"
android:layout_marginBottom="10sp"
android:clipToPadding="false" />
<ImageView
android:id="@+id/img_offer"
android:layout_width="fill_parent"
android:layout_height="70sp"
android:layout_below="@+id/lst_data"
android:adjustViewBounds="true"
android:background="@drawable/offers_btn"
android:scaleType="fitXY" />
</RelativeLayout>
如何解决我的问题。谢谢。
最佳答案
您目前告诉布局充气器要做的是将标题布局 rel_top
放在顶部,然后在其下方放置一个 ListView
,然后放置一个 ImageView
下面。你想要的基本上是将 ImageView
锚定到显示的底部,并在图像和标题布局之间拉伸(stretch) ListView
。
与其将 ImageView
对齐到 ListView
下方,不如将 ImageView
对齐到屏幕底部
<ImageView
android:id="@+id/img_offer"
android:layout_width="fill_parent"
android:layout_height="70sp"
**android:layout_alignParentBottom="true"**
android:adjustViewBounds="true"
android:background="@drawable/offers_btn"
android:scaleType="fitXY" />
并将 ListView
对齐到 rel_top
下方和 ImageView
上方
<ListView
android:id="@+id/lst_data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rel_top"
**android:layout_above="@+id/img_offer"**
android:layout_marginBottom="10sp"
android:clipToPadding="false" />
关于android - 如何在 Android 中将 Imageview 置于 Listview 下方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21318786/