[英]Horizontal ScrollView above a Button from LinearLayout
What I wish to achieve is something like this: 我想要实现的是这样的:
The thing is: after I tap on the circle button on the bottom layout, it appears a HorizontalScrollView with the possible colors of the product (which I will have to download). 关键是:点击底部布局上的圆圈按钮后,将出现一个HorizontalScrollView,其中包含产品的可能颜色(我必须下载)。 I tried something like this:
我尝试过这样的事情:
<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>
those 2 ImageButtons are just for testing, to watch their position on the screen (Eclipse). 那两个ImageButtons仅用于测试,以观察它们在屏幕上的位置(Eclipse)。
This code does not seem to align the horizontal scrollview above the button at all. 此代码似乎根本没有将按钮上方的水平滚动视图对齐。 Any ideas on how can I achieve that?
关于如何实现这一目标的任何想法?
PS. PS。 Another question would be: Can I make those buttons rounded, like in the pic, without creating aa class that extends Shape?
另一个问题是:是否可以像在图片中那样使这些按钮变成圆形,而无需创建扩展Shape的类?
You can't add rules placing children of a RelativeLayout
in regards of views that are not direct siblings of those views. 您不能添加规则来放置不是
RelativeLayout
对于这些视图的直接同级的视图的RelativeLayout
子级。 This means that your HorizontalScrollView
can't be placed relative to that Button
because the Button
isn't placed as a direct child for the RelativeLayout
that holds the HorizontalScrollView
. 这意味着您的
HorizontalScrollView
不能相对于该Button
放置,因为Button
并未作为拥有HorizontalScrollView
的RelativeLayout
的直接子项放置。
At best you could place the HorizontalScrollView
above the lay_productdetailed_bottombar LinearLayout
but, as I said, this would not give you positioning control relative to the Button
. 充其量,您可以将
HorizontalScrollView
放置在lay_productdetailed_bottombar LinearLayout
上方,但是,正如我所说,这不会给您相对于Button
定位控件。 Another approach would be a PopupWindow
holding the HorizontalScrollView
. 另一种方法是保存
HorizontalScrollView
的PopupWindow
。
Judging by the image you probably want the HorizontalScrollView
to be centered around the center of the Button
which can't be done in the xml layout, you can do it only by manually calculating the dimensions. 从图像判断,您可能希望
HorizontalScrollView
围绕Button
的中心居中,而这在xml布局中是无法完成的,您只能通过手动计算尺寸来做到这一点。
Can I make those buttons rounded, like in the pic, without creating aa class that extends Shape?
是否可以像在图片中那样使这些按钮变圆,而无需创建扩展Shape的类?
No, you'll need to create it yourself. 不,您需要自己创建它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.