0

I am working on creating a page with a layout with header "Account Information" (ref.. image). Followed by a table and i need to populate the table dynamically after fetching from server but not able to do so. Below is the .xml file and attached is the image:

    <LinearLayout
        android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@layout/header_gradient" >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_weight="0.20"
            android:gravity="center_horizontal"
            android:padding="15dp"
            android:text="@string/my_account_header_text"
            android:textColor="#ffffff"
            android:textSize="24sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="#ffffff" >

        <RelativeLayout
            android:id="@+id/my_activity_layout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="#ffffff" >

            <TextView
                android:id="@+id/my_acc_component"
                android:layout_width="158dp"
                android:layout_height="wrap_content"
                android:text="@string/my_account_component"
                android:textColor="#372c24"
                android:textSize="@dimen/login_credentials_txt" />

            <TextView
                android:id="@+id/my_acc_details"
                android:layout_width="158dp"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/my_acc_component"
                android:text="@string/my_account_details"
                android:textColor="#372c24"
                android:textSize="@dimen/login_credentials_txt" />
        </RelativeLayout>
    </LinearLayout>

</LinearLayout>
Ahmad
  • 69,608
  • 17
  • 111
  • 137

2 Answers2

1

This may not be your issue, since I don't know what the problem is yet, but there is an issue that I see. When using weight in a LinearLayout with a vertical orientation your height should be 0dp. Similarly, if it is a horizontal orientation then width should be 0dp. So for example you would change your layouts to

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="#ffffff" >

and

<RelativeLayout
        android:id="@+id/my_activity_layout"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="#ffffff" >

Also, this is definitely not whatever your problem is but fill_parent is deprecated and match_parent should be used instead.

codeMagic
  • 44,549
  • 13
  • 77
  • 93
0
*Actually, there is a problem with the weight property... if you are working with weight then you better use weight_sum property in the LinearLayout and give your textView or other view an percentage depending on your giver weight_sum value in the parent layout...
However,I think what you are looking for is something like this:*  


<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center|top"
 <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/header"
android:background="@drawable/image" // if you want your title/header to be upon the image. Or just create another ImageView for that image
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:orientation="horizontal"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:margin_Top="50dp"
android:weight="50"
android:id="@+id/my_acc_component"
android:text="your text"
android:textSize="your Size"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:margin_Top="50dp"
android:weight="50"
android:id="@+id/my_acc_details"
android:text="your text"
android:textSize="your Size"
/>
</LinearLayout>
</RelativeLayout>
androCoder-BD
  • 498
  • 7
  • 13