我正在尝试在 android 中创建一个自定义视图(或更好的布局),它用作 2 个子视图的容器(将其视为垂直分隔 2 个容器的条形图,可以上下滑动)。
我想像 xml 中的布局一样使用它,以便您可以在其中嵌套任何视图。
我想到了类似的事情:
<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>
该 xml 应该为我提供两个按钮之间的可滑动栏。
但是,我不知道如何实现这一点,我正在扩展 LinearLayout atm,但我如何告诉我的孩子如何定位自己?
代替
<view class="at.calista.quatscha.views.SwipebarLayout"
android:id="@+id/sbl"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
您可以使用
<at.calista.quatscha.views.SwipebarLayout
android:id="@+id/sbl"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
如果您的 SwipebarLayout 类扩展了 LinearLayout,它的行为方式与您在代码中使用 LinearLayout 标记完全相同,并且您可以按照与 LinearLayout 完全相同的方式定位子级。当然,如果您重写了 LinearLayout 中的某些方法,那么功能将与该部分不同。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)