sr.*_*zad 2 android android-layout android-listview
我有我的活动布局,这个布局包含很多小部件.在我从Listview中的webservice加载的活动数据中.当listview被改编并填写所有数据时.imagview是看不见的但我想在数据加载时将Listview显示在Listview下面.
我在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>
Run Code Online (Sandbox Code Playgroud)
如何解决我的Problms.thanks.
您目前告诉布局inflater要做的是将标题布局rel_top放在顶部,然后ListView在它下面放置一个,然后在它ImageView下面放置一个.你想要的基本上是ImageView锚定到显示器的底部,并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" />
Run Code Online (Sandbox Code Playgroud)
并将其对齐在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" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1759 次 |
| 最近记录: |