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

4

2 回答 2

1

我认为您希望控件包装在它们的容器中。所以你需要一个布局控件,比如WrapLayout.WPF

在android中,您可以根据您的期望实现您的布局。

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

或者你可以编写你的实用函数来为你处理包装操作。

然后 是 Android - LinearLayout Horizo​​ntal with wrapping children

于 2013-01-21T07:32:37.693 回答
0

在您想要名称的地方插入一组带下划线样式的 Spannable 空格。然后总会有一些东西 - 在这种情况下是一个空白,下面有一条线。

于 2013-01-21T07:24:39.067 回答