Putting TextViews in relative layout

casillas

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.

enter image description here

Here is what I get:

enter image description here

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>
bryan c

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

TextViews overlapping in Relative layout

From Dev

Android: Need Ellipsis for Multiple TextViews in Relative Layout

From Dev

Adding Textviews to Relative Layout based on screen size

From Dev

wrap a layout with textviews

From Dev

LinearLayout layout 2 textviews

From Dev

Align TextViews relative to each other

From Dev

NullPointerExceptions when adding TextViews to a layout

From Dev

Linear Layout Or Relative Layout?

From Dev

Putting ImageView Over ImageView in Layout

From Dev

Putting ImageView Over ImageView in Layout

From Dev

Kivy putting buttons on the corner of layout

From Dev

Relative layout placing to other relative layout

From Dev

Zooming a layout (Relative Layout) in android

From Dev

Coordinator Layout and Relative Layout issue

From Dev

Convert a Relative Layout to a Linear Layout

From Dev

Relative layout - layout_toRightOf

From Dev

Layout issue related to "Relative Layout"

From Dev

Zooming a layout (Relative Layout) in android

From Dev

Android Layout - layouts of 3 textviews inside a listview

From Dev

Horizontally center align two textviews in a layout

From Dev

Put two textviews side by side in a layout

From Dev

How to switch between 2 TextViews places on the layout?

From Dev

Different Gravity of two textviews in a horizontal Linear Layout

From Dev

Misplaced textviews in linear weight based layout

From Dev

Custom ListView Layout with Multiple ImageViews and TextViews

From Dev

ArrayAdapter Unable to access Textviews from inflated Layout

From Dev

Missing items in a Relative Layout

From Dev

Keeping relative layout fixed

From Dev

android relative layout design

Related Related

HotTag

Archive