I am trying to add three text views as follows, but I could not able to achieve it. I want A to be on the left side, and the other two texviews to be right side.
Here is what I get:
Here is my current implementation
<RelativeLayout
android:id="@+id/mainlayout"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:background="#363636">
<TextView
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="A"
android:textColor="@android:color/white"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:textSize="16sp"
android:fontFamily="sans-serif-medium" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:id="@+id/innerLayout">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:text="B "
android:textSize="16sp"
android:textColor="@android:color/white"
android:paddingRight="8dp" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:text="C "
android:textSize="16sp"
android:textColor="@android:color/white"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:paddingLeft="8dp"
android:paddingRight="8dp" />
</RelativeLayout>
</RelativeLayout>
use this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:id="@+id/A"
android:text="aaaaaaa"
android:padding="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:id="@+id/C"
android:text="ccccccc"
android:padding="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/C"
android:id="@+id/B"
android:text="bbbbbbb"
android:padding="8dp"/>
</RelativeLayout>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments