由网友(闹够了没有)分享简介:我在我的应用程序这个code:I have this code in my application:LinearLayout.LayoutParams params =new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);和我只是想给的LinearLay...
我在我的应用程序这个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);
相关推荐
最新文章