0

I am trying a profile pic with name and email address in the linear Layout strangely this isn't coming up properly when I see in Graphical layout in eclipse I am not sure what is wrong.

Here is what I would like to expect:

enter image description here

Here is how it shows up:

enter image description here

Here is the code that I am using:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearTotalLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
android:baselineAligned="false"
android:orientation="horizontal" >

<LinearLayout
    android:id="@+id/LinearLayoutforImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight=".20" >

    <ImageView
        android:id="@+id/imageforprofile"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:paddingBottom="10dp"
        android:paddingTop="10dp"
        android:src="@drawable/profilepic" >
    </ImageView>
</LinearLayout>

<LinearLayout
    android:id="@+id/LinearLayoutforText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="left|center"
    android:layout_weight=".80"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textforprofile"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="left"
        android:text="testing"
        android:textColor="#FFFFFF"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/textforprofileemail"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="left"
        android:text="[email protected]"
        android:textColor="#FFFFFF"
        android:textStyle="bold" />
    </LinearLayout>

    </LinearLayout>

I am not sure where I am going wrong? Can somebody help me with this?

1
  • is this an xml for listView item?? Commented Jul 29, 2014 at 3:28

3 Answers 3

3

Your very first LinearLayout (android:id="@+id/LinearTotalLayout") should have layout_height="wrap_content". That's all :)

Sign up to request clarification or add additional context in comments.

1 Comment

My bad.. I didn't try that part.. Thanks this worked!
1

This will work according to your needs

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearTotalLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg"
android:baselineAligned="false"
android:orientation="horizontal" >

<LinearLayout
    android:id="@+id/LinearLayoutforImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight=".20" >

    <ImageView
        android:id="@+id/imageforprofile"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:paddingBottom="10dp"
        android:paddingTop="10dp"
        android:src="@drawable/profilepic" >
    </ImageView>
</LinearLayout>

<LinearLayout
    android:id="@+id/LinearLayoutforText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="left|center"
    android:layout_weight=".80"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textforprofile"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="left"
        android:text="testing"
        android:textColor="#FFFFFF"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/textforprofileemail"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="left"
        android:text="[email protected]"
        android:textColor="#FFFFFF"
        android:textStyle="bold" />
    </LinearLayout>

    </LinearLayout>

Comments

0

Change android:layout_height="wrap_content"

code will be like this;

  <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/LinearTotalLayout"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="@drawable/bg"
 android:baselineAligned="false"
 android:orientation="horizontal" >

<LinearLayout
android:id="@+id/LinearLayoutforImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".20" >

<ImageView
    android:id="@+id/imageforprofile"
    android:layout_width="75dp"
    android:layout_height="75dp"
    android:paddingBottom="10dp"
    android:paddingTop="10dp"
    android:src="@drawable/profilepic" >
    </ImageView>
 </LinearLayout>

   <LinearLayout
   android:id="@+id/LinearLayoutforText"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="left|center"
   android:layout_weight=".80"
   android:orientation="vertical" >

  <TextView
    android:id="@+id/textforprofile"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="left"
    android:text="testing"
    android:textColor="#FFFFFF"
    android:textStyle="bold" />

<TextView
    android:id="@+id/textforprofileemail"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="left"
    android:text="[email protected]"
    android:textColor="#FFFFFF"
    android:textStyle="bold" />
</LinearLayout>

</LinearLayout>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.