首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android应用程序的相对布局有2-3元素和底部按钮

Android应用程序的相对布局有2-3元素和底部按钮
EN

Stack Overflow用户
提问于 2015-03-24 20:11:33
回答 1查看 277关注 0票数 0

我想设计一个具有相对布局的android活动。在彼此之间的垂直线中应该有3个(或以后的4个)元素。我试过了,但是textview隐藏在listview后面。

如果我想在文本和listview或listview和按钮之间插入第四个元素,那么代码有什么问题,我应该如何更改它以及它的外观.就像一幅图像。

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:paddingLeft="10dp"
    android:paddingRight="10dp" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView
        android:id="@+id/textview"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:paddingBottom="10dp"
        android:layout_above="@+id/listview"
        android:text="@string/info" />

    <ListView
        android:id="@+id/listview"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/button"
        android:layout_marginBottom="10dp" />

    <ImageButton
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:onClick="start"
        android:src="@drawable/button1" />

</RelativeLayout>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-24 21:10:38

尝试将ReltiveLayout更改为LinearLayout,或者将LinearLayout放在RelativeLayout之外,orientation="vertical"TextView放在RelativeLayout之外。就像这样:

代码语言:javascript
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical">

   <TextView
       android:id="@+id/textview"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/info" />

   <RelativeLayout
       android:paddingLeft="10dp"
       android:paddingRight="10dp" 
       android:layout_width="fill_parent"
       android:layout_height="fill_parent">

       <ListView
           android:id="@+id/listview"
           android:layout_width="fill_parent"
           android:layout_height="match_parent"
           android:layout_above="@+id/button"
           android:layout_marginBottom="10dp" />

       <ImageButton
           android:id="@+id/button"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_alignParentBottom="true"
           android:layout_centerHorizontal="true"
           android:onClick="start"
           android:src="@drawable/button1" />

   </RelativeLayout>

</LinearLayout>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29241972

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档