2014-09-26 106 views
0

我做了一個android應用程序,其中包含scrollview佈局和裏面的AbsoluteLayout,問題是我無法顯示佈局的底部它只顯示佈局的頂部。我試圖在AbsoluteLayout中使用layout_marginBottom,但它不起作用。android無法顯示佈局的底部

+0

使用相對佈局或已LinearLayout中棄用.. – Ranjit 2014-09-26 13:01:07

+0

你想要什麼顯示在佈局的底部.. – Ranjit 2014-09-26 13:02:23

+0

@Ranjit帕蒂我加在圖片這個問題。 – 2014-09-26 13:19:55

回答

2

使用RelativeLayout,而不是AbsoluteLayout。也不要滾動總佈局。只需滾動View

檢查一次:不是Absolute..It

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:layout_marginLeft="40dp" 
android:layout_marginRight="40dp" 
android:layout_marginTop="40dp" 
android:background="@drawable/bg" > 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="300dp" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:text="TextView" /> 

</ScrollView> 

<Button 
    android:id="@+id/btn1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:text="Button" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/btn1" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="27dp" 
    android:text="@string/s3" 
    android:textSize="16sp" 
    android:text="TextView" /> 

</RelativeLayout> 
0

使用的RelativeLayout,並設置左,右頁邊距像

RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); 
lp.leftMargin = x; 
lp.topMargin = y; 
0

真實的,絕對佈局已被棄用。此外,這裏有一個提示:

爲Android創建xml佈局時,檢查錯誤的最簡單方法是使用xml佈局文件的「圖形佈局」選項卡。 Graphical layout editor 。使用適當的設備配置(匹配您的設備)和API版本,重現該錯誤並查看更改佈局參數是否有幫助。

+0

它在圖形佈局上看起來很完美,但在模擬器或手機中測試時,它並不顯示整個佈局。 – 2014-09-26 13:19:17

0

使用性質的android:fillViewPort =內滾動型真如下

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:fillViewport="true" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/bg" 
android:orientation="vertical" >