Reputation: 434
I'm trying to create an android layout where I have an imageview along with a two column textview directly to the right of it all within a scrollview.
Think like a users profile picture and basic information layout.
I've created a wireframe of what I am trying to achieve, unfortunately I just can't seem to get the layout of the imageview - textview - textview correct.
Everything else I have done.
EDIT This is what I have tried without an luck:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:layout_weight="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:weightSum="1"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weight="0.4"
android:src="@drawable/profileImg" />
<LinearLayout
android:weight="0.6"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:weightSum="1"
android:orientation="vertical">
<RelativeLayout
android:weight="0.25">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp"
android:text="User ID"
android:textColor="#fff" />
<TextView
android:id="@+id/pUID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp"
android:text="pUID"
android:textColor="#fff" />
</RelativeLayout>
<RelativeLayout
android:weight="0.25">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp"
android:text="Full Name"
android:textColor="#fff" />
<TextView
android:id="@+id/fName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp"
android:text="fName"
android:textColor="#fff" />
</RelativeLayout>
<RelativeLayout
android:weight="0.25">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp"
android:text="Age"
android:textColor="#fff" />
<TextView
android:id="@+id/pAge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp"
android:text="pAge"
android:textColor="#fff" />
</RelativeLayout>
<RelativeLayout
android:weight="0.25">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp"
android:text="Date of Birth"
android:textColor="#fff" />
<TextView
android:id="@+id/pDOB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp"
android:text="pDOB"
android:textColor="#fff" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Upvotes: 0
Views: 65
Reputation: 4497
Try using the next XML file
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp">
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView48"
android:textSize="24sp"/>
</LinearLayout>
<LinearLayout
android:weight="0.6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.30">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weight="0.4"
android:src="@drawable/profileImg"
android:layout_marginLeft="10dp"/>
</LinearLayout>
<LinearLayout
android:weight="0.25"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.70">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<LinearLayout
android:weight="0.25"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="TextView"
android:textColor="#000"
android:textSize="24sp"/>
</LinearLayout>
<LinearLayout
android:weight="0.25"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24sp"
android:text="TextView"
android:textColor="#000" />
</LinearLayout>
<LinearLayout
android:weight="0.25"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24sp"
android:text="TextView"
android:textColor="#000" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<LinearLayout
android:weight="0.25"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="TextView"
android:textColor="#000"
android:textSize="24sp"/>
</LinearLayout>
<LinearLayout
android:weight="0.25"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24sp"
android:text="TextView"
android:textColor="#000" />
</LinearLayout>
<LinearLayout
android:weight="0.25"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24sp"
android:text="TextView"
android:textColor="#000" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal">
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView83"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:textSize="18sp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewb"
android:textColor="#000"
android:textSize="24sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewc"
android:textColor="#000"
android:textSize="24sp"
android:layout_marginTop="20dp"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewd"
android:textColor="#000"
android:textSize="24sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewe"
android:textColor="#000"
android:textSize="24sp"
android:layout_marginTop="20dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Output
Upvotes: 2
Reputation: 783
RelativeLayout
with an ImageView
and 2 LinearLayout
. The LinearLayouts
will contain the TextViews
.
The ImageView
will be allignParentLeft
and the other two layouts will have weights of 1 and layout to the left of the image view.
Upvotes: 0