如何在 RelativeLayout 中添加 LinearLayout ,其中动态内容从数据库加载到 Relativelayout 中?
How to add LinearLayout in RelativeLayout , where dynamic contents loaded in Relativelayout from DB?
如何在 RelativeLayout 中添加 LinearLayout ,动态内容从数据库加载到 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>
这是我的回答。您可以使用 new LinearLayout 向 contentLayout 添加新行,例如 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>
如何在 RelativeLayout 中添加 LinearLayout ,动态内容从数据库加载到 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>
这是我的回答。您可以使用 new LinearLayout 向 contentLayout 添加新行,例如 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>