2014-07-11 81 views
0

我有主RelativeLayout佈局文件。我在這個scrollview裏面有scrollview和兩個按鈕和listview。我有一個問題,當我運行程序時,它顯示了listview.my中只有一個項目是xml文件。我如何改變我的問題?android RelativeLayout下面不能正常工作

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


<ScrollView 

    android:id="@+id/scrollview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 

    > 



<RelativeLayout 
    android:id="@+id/layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="50dp" 
    android:background="#5f2585" > 

    <Button 
     android:id="@+id/studia" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:background="@drawable/n_button" 
     android:text="სტუდია" 
     android:textColor="#ffffff" /> 

    <ListView 
     android:id="@+id/menu_listview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/studia" 
     android:divider="@null" 

     > 
    </ListView> 

    <Button 
     android:id="@+id/gadacema" 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_below="@+id/menu_listview" 
     android:background="@drawable/n_button" 
     android:text="გადაცემა" 
     android:textColor="#ffffff" /> 
</RelativeLayout> 

在編程一切正常(如果我刪除滾動視圖,然後我可以顯示所有值,但我不能顯示按鈕女巫是低於列表視圖

什麼是錯誤的,我的XML文件。 ?我怎樣才能解決這個問題

+0

嵌套滾動視圖('ScrollView'和'ListView')通常不是一個好主意,你確定你需要這個嗎?然後,你的'LinearLayout'沒有用,因爲它只有一個'ScrollView'。嘗試儘可能簡單地創建您的XML。你會更容易找到錯誤,對演出來說更好。 –

回答

2

請試試這個

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    > 



<RelativeLayout 
    android:id="@+id/layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="50dp" 
    android:background="#5f2585" > 

    <Button 
     android:id="@+id/studia" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:background="@drawable/n_button" 
     android:text="სტუდია" 
     android:textColor="#ffffff" /> 

    <ListView 
     android:id="@+id/menu_listview" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/studia" 
     android:divider="@null" 

     > 
    </ListView> 

    <Button 
     android:id="@+id/gadacema" 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_below="@+id/menu_listview" 
     android:background="@drawable/n_button" 
     android:text="გადაცემა" 
     android:textColor="#ffffff" /> 
</RelativeLayout> 
</LinearLayout> 
</ScrollView> 
+0

謝謝我試了一下,但沒有變化:( – user3804530

+1

我認爲你必須改變列表視圖的高度'android:layout_height =「match_parent」' –

+0

我試過了但是...... – user3804530

0

試試這個: - 。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    > 
     <Button 
      android:id="@+id/studia" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:background="@drawable/n_button" 
      android:text="სტუდია" 
      android:textColor="#ffffff" /> 

     <ListView 
      android:id="@+id/menu_listview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/studia" 
      android:divider="@null"/> 


     <Button 
      android:id="@+id/gadacema" 
      android:layout_width="match_parent" 
      android:layout_height="40dp" 
      android:layout_below="@+id/menu_listview" 
      android:background="@drawable/n_button" 
      android:text="გადაცემა" 
      android:textColor="#ffffff" /> 

</RelativeLayout> 
+0

謝謝你我試過但沒有變化:( – user3804530

+0

@ user3804530,現在看到我編輯的答案.... – Laxmeena