-3

I want to create a fill in the blank type of question. Where the user drags and drops the answer in the empty space.

My Name is _____. Or < Some long text > _______ < Some other text >.

What I did :

I used Horizontal linear layout but the problem is some of the views disappear specially when the text is too long or they will not be positioned exactly after the text view. Any idea how i can concatenate those views . TextView + Empty Layout + TextView. excatly the way i showed above .

Thanks

Here is the Code .....

Layout XML

android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/thequestionLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/start_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Some text" />

    <LinearLayout
        android:id="@+id/blank_space"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/shape" >
    </LinearLayout>

    <TextView
        android:id="@+id/end_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="end text" />
</LinearLayout>

<!-- Here are the choices -->

<LinearLayout
    android:id="@+id/theChoicesLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center" >

    <TextView
        android:id="@+id/choice1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

    <TextView
        android:id="@+id/choice2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

    <TextView
        android:id="@+id/choice3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />
</LinearLayout>

2 Answers2

1

I think you expect the controls are wrapped in their container. So you need a layout control like WrapLayout of WPF.

In android, you can implement your layout according to your expectation.

http://nishantvnair.wordpress.com/2010/09/28/flowlayout-in-android/

Or you can write your utility function that handles wrapping operation for you.

Then Android - LinearLayout Horizontal with wrapping children

Community
  • 1
  • 1
ibrahimyilmaz
  • 18,331
  • 13
  • 61
  • 80
0

Insert a set of spaces inside a Spannable with underline style where you want the name. Then there will always be something there- in this case a blank with a line under it.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • Thanks for the answer. This will only show a space but what i want is to concatinate a view not specific line. I edited the question. So could you please look at it again. Thanks – user1013008 Jan 21 '13 at 08:36