Parth Anjaria
Parth Anjaria

Reputation: 3971

Layouting, not able to achieve

I would like to create this layout : enter image description here

This is the code i used :

<RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/ans_bg_normal"
            android:padding="@dimen/padding25"
            android:gravity="center_vertical"
            >
            <com.app.quizjeetho.Fonts.TextView_Bold
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ans_circle_normal"
                android:id="@+id/option1_a"
                />

            <com.app.quizjeetho.Fonts.TextView_Bold
                android:id="@+id/option1"
                android:textSize="15sp"
                android:textColor="@color/white"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="asdsdddadsadasdasdsadasdsadddsf"
                android:layout_centerInParent="true"
                />
        </RelativeLayout>

I am getting this output from this :

enter image description here

The text is overlapping, how do I solve this?

Upvotes: 0

Views: 41

Answers (3)

yogesh lokhande
yogesh lokhande

Reputation: 1275

I think getting separate background images for every option might help or you can take two different images for background

  1. for question number and
  2. for background of your option layout.

Upvotes: 0

NST
NST

Reputation: 15

Add the following to your RelativeLayout to make it work

<com.app.quizjeetho.Fonts.TextView_Bold
    android:id="@+id/option1"
    android:textSize="15sp"
    android:textColor="@color/white"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toEndOf="@id/option1_a"
    android:layout_centerVertical="true"
    android:text="asdsdddadsadasdasdsadasdsadddsf" />

Aligning this layout to the end of the first layout will do the trick

Upvotes: 1

Kuldeep Kulkarni
Kuldeep Kulkarni

Reputation: 796

Try to set weight like this & see is it working or not:

<LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/ans_bg_normal"
            android:padding="@dimen/padding25"
            android:gravity="center_vertical"
            android:orientation="horizontal" 
            android:weightSum="1">

            <com.app.quizjeetho.Fonts.TextView_Bold
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ans_circle_normal"
                android:id="@+id/option1_a"
                 android:layout_weight=".3"/>

            <com.app.quizjeetho.Fonts.TextView_Bold
                android:id="@+id/option1"
                android:textSize="15sp"
                android:textColor="@color/white"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="asdsdddadsadasdasdsadasdsadddsf"
                android:layout_centerInParent="true"
                android:layout_weight=".7"/>
        </LinearLayout>

Upvotes: 0

Related Questions