我正在尝试在android中创建一个自定义视图(或者更好的布局),作为两个子视图的容器(可以将其视为垂直分隔两个容器的栏,可以上下滑动)。
我想像使用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自动取款机,但我如何告诉我的孩子如何定位自己?
发布于 2010-12-20 20:16:08
而不是
<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中的某些方法,那么其功能将与该部分不同。
https://stackoverflow.com/questions/4489337
复制相似问题