在code布局方向 [英] Layout orientation in code
本文介绍了在code布局方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用程序这个code:
I have this code in my application:
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
和我只是想给的LinearLayout的方向设定为垂直。在XML等效为:
and I just want to set the orientation of the LinearLayout to vertical. The equivalent in XML is:
android:orientation="vertical"
我怎样才能做到这一点,在code,而不XML?
How can I do it in the code, without XML?
推荐答案
您不能更改的LinearLayout
的使用方向的的LayoutParams
。它只能与的LinearLayout
对象来完成。
You can't change LinearLayout
's orientation using its LayoutParams
. It can be done only with a LinearLayout
object.
LinearLayout layout = /* ... */;
layout.setOrientation(LinearLayout.VERTICAL);
这篇关于在code布局方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文