Krešimir Čulina
Krešimir Čulina

Reputation: 93

Android Widget - Two Lines?

I'm trying to make a simple widget and I need to make it in two lines. Apparently I can't use a table for that, so I'm a bit stuck on how to do it.

This is my code

    <FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="65dp"
    android:layout_gravity="top" >

</FrameLayout>

<FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="65dp"
    android:layout_gravity="bottom"
    android:layout_weight="1" >

</FrameLayout>

And this is what I'm trying to do

https://i.sstatic.net/n8Jc7.jpg

Upvotes: 0

Views: 66

Answers (3)

sebster
sebster

Reputation: 1320

Are you using your <FrameLayout> as containers for dynamically added Fragments or something else?

If yes then use a <RelativeLayout> to wrap the two <FrameLayout> and use android:layout_below="" to align one below the other.

Otherwise just use Ahmad's example.

Upvotes: 0

Prateek
Prateek

Reputation: 4013

I would suggest using a Relativelayout to achieve this as from your image I can see that you want to ovelay things on some other layout and in this case you would require a FrameLayout or RelativeLayout and LinearLayout won't do.

Upvotes: 1

Ahmad
Ahmad

Reputation: 72563

Why don't use a LinearLayout?

<LinearLayout
android:orientation="vertical"
[...]
>

<LinearLayout
android:id="@+id/myFirstRow"
[...]
>
<myUiElements />
</LinearLayout>

<LinearLayout
android:id="@+id/mySecondRow"
[...]
>
<myUiElements />
</LinearLayout>

</LinearLayout>

Upvotes: 1

Related Questions