0

我希望实现的是这样的:

H&M 安卓应用

问题是:在我点击底部布局上的圆形按钮后,它会出现一个带有产品可能颜色的 Horizo​​ntalScrollView(我将不得不下载)。我试过这样的事情:

 <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <LinearLayout
            android:id="@+id/lay_productdetailed_bottombar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/transparent"
            android:gravity="center_vertical"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/btn_productdetailed_fullscreen"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Full" />

            <Button
                android:id="@+id/btn_productdetailed_colors"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Colors" />

            <Button
                android:id="@+id/btn_productdetailed_sizes"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Sizes" />

            <Button
                android:id="@+id/btn_productdetailed_buy"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Buy" />
        </LinearLayout>

        <HorizontalScrollView
            android:id="@+id/hscroll_productdetailed_colors"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/btn_productdetailed_colors" >

            <LinearLayout
                android:id="@+id/lay_productdetailed_colors"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="2dp" >

                <ImageButton
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:layout_gravity="center_vertical" />

                <ImageButton
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:layout_gravity="center_vertical" />
            </LinearLayout>
        </HorizontalScrollView>
    </RelativeLayout>

这 2 个 ImageButton 仅用于测试,以观察它们在屏幕上的位置(Eclipse)。

此代码似乎根本没有对齐按钮上方的水平滚动视图。关于如何实现这一目标的任何想法?

PS。另一个问题是:我可以像图片中那样使这些按钮变圆,而不创建扩展 Shape 的类吗?

4

1 回答 1

0

RelativeLayout对于不是这些视图的直接兄弟的视图,您不能添加放置 a 的子级的规则。这意味着你HorizontalScrollView不能相对于那个放置,Button因为Button它没有被放置为 RelativeLayout持有HorizontalScrollView.

充其量您可以将其HorizontalScrollView放在lay_productdetailed_bottombar 上方,LinearLayout但正如我所说,这不会为您提供相对于Button. 另一种方法是PopupWindow持有HorizontalScrollView.

从图像来看,您可能希望以xml 布局中无法完成HorizontalScrollView的中心为中心,您只能通过手动计算尺寸来做到这一点。Button

我可以像图片中那样使这些按钮变圆,而无需创建扩展 Shape 的类吗?

不,您需要自己创建它。

于 2013-05-20T09:06:48.647 回答