Android: creating a custom container

I am trying to create a custom view (or better, a layout) in android that serves as a container for two child views (think of it as a panel that divides 2 containers vertically that can be scrolled up and down).

I would like to use it as a layout in xml so that you can embed all kinds into it. I thought of something like this:   

            <view class="at.calista.quatscha.views.SwipebarLayout"
            android:id="@+id/sbl"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <!-- Top View -->
            <Button android:text="Top" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

            <!-- Bottom View -->
            <Button android:text="Bottom" android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</view>

This xml should give me a scrollable bar between two buttons.

However, I do not know how to do this, I am expanding LinearLayout atm, but how will I tell my children how to position myself?

+3
source share
1 answer

instead

<view class="at.calista.quatscha.views.SwipebarLayout"
        android:id="@+id/sbl"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

you can use

<at.calista.quatscha.views.SwipebarLayout
        android:id="@+id/sbl"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

SwipebarLayout LinearLayout, , LinearLayout, , LinearLayout. , LinearLayout, .

+1

Source: https://habr.com/ru/post/1781220/


All Articles