如何管理相对布局动态控制? [英] How to manage control in relative layout Dynamically?
问题描述
一个设计问题相对布局。其实我想这种类型的OUT输出。
这一切应该是动态的。
我从激励
<一href=\"http://stackoverflow.com/questions/11736658/android-heterogeneous-gridview-like-pinterest\">Android异构gridview的像Pinterest的?
我想添加两个按钮一样 - 不喜欢在右上角
。我能做到这一点的布局完美,但如何添加两个按钮动态,我不知道。
按我的思维相对布局仅仅是实现这一目标的方式输出。如果有任何替代解决方案,请分享。
请指引我它的真正AP preciated。
感谢分析我的问题。
我想添加像两个按钮 - 不喜欢在右上角。我可以
该布局完美,但如何动态地添加这两个按钮
我不知道。
按我的思维相对布局仅仅是实现这一目标的方式输出。
如果有任何替代解决方案,请分享。
块引用>
RelativeLayout的
不是做单一的方式,但它是这样做的最有效方法。你可以,例如包裹的ImageView
在的FrameLayout
,也把那些二两按钮
在一个水平的LinearLayout
。然后,您将地方的LinearLayout
在的FrameLayout
使用layout_gravity
设置为底部|权
。但RelativeLayout的
是去,因为你会避免使用包装容器和两个之间的一个额外的布线方式按钮
。对于RelativeLayout的
你必须在布局的末尾:&LT;&RelativeLayout的GT;
&LT; ImageView的宽度|高度= FILL_PARENT /&GT;
&LT;按键宽度|高度= WRAP_CONTENT的Android =@ + ID /不喜欢
机器人:layout_alignParentRight =真
机器人:layout_alignParentBottom =真/&GT;
&LT;按键宽度|高度= WRAP_CONTENT的Android =@ + ID /像
机器人:layout_toLeftOf =@ ID /不喜欢
机器人:layout_alignParentBottom =真/&GT;
&LT; / RelativeLayout的&GT;如果您添加
按钮
在code,你会设置RelativeLayout.LayoutParams
为按钮
,并设置相应的规则,在XML布局那些的LayoutParams
。One designing issue in relative layout. Actually i want this type out output.
This all should be dynamically. I inspire from Android heterogeneous gridview like pinterest?
i want to
add two buttons like - Dislike in right corner
. i can do that layout perfectly but how to add that two button dynamically that i don't know.As per my thinking relative layout is only way to achieve this output. if there are any alternative solution please share it.
Please guide me it's truly appreciated.
Thanks for analyze my question.
解决方案i want to add two buttons like - Dislike in right corner. i can do that layout perfectly but how to add that two button dynamically that i don't know. As per my thinking relative layout is only way to achieve this output. if there are any alternative solution please share it.
RelativeLayout
is not the single way to do it but it's the most efficient way to do it. You could, for example wrap theImageView
in aFrameLayout
and also put those two twoButtons
in a horizontalLinearLayout
. You'll then place thatLinearLayout
in theFrameLayout
usinglayout_gravity
set tobottom|right
. ButRelativeLayout
is the way to go because you'll avoid using an extra layout between the wrapper container and the twoButtons
. For aRelativeLayout
you'll have at the end of the layout:<RelativeLayout> <ImageView width|height=fill_parent /> <Button width|height=wrap_content android="@+id/dislike" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" /> <Button width|height=wrap_content android="@+id/like" android:layout_toLeftOf="@id/dislike" android:layout_alignParentBottom="true" /> </RelativeLayout>
If you add the
Buttons
in code you would setRelativeLayout.LayoutParams
for theButtons
and also set the appropriate rules as in the xml layout for thoseLayoutParams
.这篇关于如何管理相对布局动态控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!