2015-10-04 29 views
1

如何在RelativeLayout中添加LinearLayout,其中動態內容是從DB中的Relativelayout中加載的?我希望在頁面的最後加載按鈕。文本&圖像作爲來自數據庫的行數加載。如何在RelativeLayout中添加LinearLayout,其中動態內容是從DB中的Relativelayout中加載的?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="wrap_content" android:id="@+id/rowLayout" android:background="@android:color/holo_orange_dark"> 



<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> 
<ImageView android:id="@+id/profileImg" 
    android:layout_width="20dp" 
    android:layout_height="20dp" 
    android:layout_marginLeft="14px" 
    android:layout_marginRight="10px" 
    android:layout_marginTop="4px" android:layout_gravity="left" 
    android:src="@drawable/checkmark" > 
</ImageView> 
<TextView 
    android:id="@+id/origin" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@+id/label" 
    android:textColor="@android:color/white" 
    android:layout_marginTop="20dp" 
    android:textSize="20dp" android:layout_alignParentRight="true"> 
</TextView>`</LinearLayout> <LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">` 

    <Button 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:textColor="#ffffff" android:text="ADD POOL" android:layout_gravity="center|center_vertical" 
     android:background="#ff9b0c" android:onClick="serviceMessage" /> 
</LinearLayout> </RelativeLayout> 

回答

0

這是我的答案。您可以使用新的LinearLayout向rowLayout添加新行,如rowLayout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/root" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@android:color/holo_orange_dark" 
android:orientation="vertical" > 

<LinearLayout 
    android:id="@+id/contentLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <LinearLayout 
     android:id="@+id/rowLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <ImageView 
      android:id="@+id/profileImg" 
      android:layout_width="20dp" 
      android:layout_height="20dp" 
      android:layout_gravity="left" 
      android:layout_marginLeft="14px" 
      android:layout_marginRight="10px" 
      android:layout_marginTop="4px" 
      android:src="@drawable/checkmark" > 
     </ImageView> 

     <TextView 
      android:id="@+id/origin" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_marginTop="20dp" 
      android:text="@+id/label" 
      android:textColor="@android:color/white" 
      android:textSize="20dp" > 
     </TextView> 
    </LinearLayout> 
</LinearLayout> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@id/contentLayout" 
    android:layout_centerHorizontal="true" 
    android:background="#ff9b0c" 
    android:onClick="serviceMessage" 
    android:text="ADD POOL" 
    android:textColor="#ffffff" /></RelativeLayout> 
+0

謝謝@Danh,它更改了按鈕可見的格式。我希望按鈕在頁面末尾顯示行時按下一次。 – prasoons

+0

你可以使用ScrollView是ContentLayout的父項:) – DanhLoi

相關問題