简体   繁体   English

两个ListViews和一个按钮

[英]Two ListViews and One Button

I'm doing an android app and I want to separate layout in 3 parts like this: 我正在做一个android应用,我想将布局分成3个部分,如下所示:

在此处输入图片说明

but now the button is over the second listview but on the bottom of the screen, I don't know why. 但是现在按钮在第二个列表视图上方,但在屏幕底部,我不知道为什么。

I don't know if I have to use relativeLayout or linearLayout to including the listviews, and text are inside this or outside of relativelayout/linearLayout, and the last button what? 我不知道我是否必须使用relativeLayout或linearLayout来包括列表视图,并且文本在这个之中还是在relativelayout / linearLayout之外,最后一个按钮是什么?

this is my code: 这是我的代码:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:orientation="vertical" >

   <TextView android:id="@+id/imageSelected"
          android:text="@string/imgSelected"
          android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:layout_marginBottom="3dip"/>

   <LinearLayout 
     android:id="@+id/linearLayoutImagenes"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentTop="true"
     android:layout_below="@+id/imageSelected" >

   <ListView
      android:id="@+id/listaFusionPhotos"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" 
      />

   </LinearLayout >

    <TextView android:id="@+id/nameSelected"
          android:text="@string/namSelected"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:layout_below="@+id/linearLayoutImagenes"
          android:layout_marginBottom="3dip"/>


<LinearLayout  
  android:id="@+id/linearLayoutNombres"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_below="@+id/nameSelected"
      >

    <ListView
       android:id="@+id/listaFusionNombres"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"/>

   </LinearLayout >

   <Button
      android:id="@+id/fusion"
      android:layout_width="160dip"
      android:layout_height="wrap_content"
      android:layout_below="@+id/linearLayoutNombres"
      android:layout_marginTop="3dip"
      android:text="Fusionar" 
      android:onClick="Mostrar_Registrados"
      android:layout_alignParentBottom="true"/>



</RelativeLayout>

Try this. 尝试这个。 this looks like exactly same of the picture. 看起来和图片完全一样。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="11" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:layout_weight="1"/>

<ListView
    android:id="@+id/listView1"
    android:layout_width="fill_parent"
    android:layout_height="0dp" 
    android:layout_weight="4">
</ListView>

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
   android:layout_height="0dp"
    android:layout_weight="1"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<ListView
    android:id="@+id/listView2"
    android:layout_width="fill_parent"
    android:layout_height="0dp" 
    android:layout_weight="4">
</ListView>

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:text="Button" />

</LinearLayout>
<LinearLayout  
     android:id="@+id/linearLayoutNombres"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_below="@+id/nameSelected"
      android:layout_above="@+id/fusion" // "line added"
>
    <Button
      android:id="@+id/fusion"
      android:layout_width="160dip"
      android:layout_height="wrap_content"
      android:layout_below="@+id/linearLayoutNombres" --> "remove this line"
      android:layout_marginTop="3dip"
      android:text="Fusionar" 
      android:onClick="Mostrar_Registrados"
      android:layout_alignParentBottom="true"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM