android - 如何设置android :orientation ="horizontal" programmatically in RelativeLayout?

标签 android android-layout

如何在 RelativeLayout 中像这样以编程方式设置 android:orientation="horizo​​ntal":

<RelativeLayout
                android:id="@+id/ID"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >

</RelativeLayout>

这是我目前所拥有的:

RelativeLayout rLayout = new RelativeLayout(getActivity());
LayoutParams layoutParams;
layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
rLayout.setLayoutParams(layoutParams);

最佳答案

正如您在 the docs 中看到的那样, RelativeLayout 没有 orientation 参数。

关于android - 如何设置android :orientation ="horizontal" programmatically in RelativeLayout?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20458542/

相关文章:

java - Android Sqlite 表未创建

android - 在 AppCompat v23 中禁用 ActionMode 的动画

android-layout - 动态设置 View 样式 : Android

android - 图书馆 koush/ion 未显示进度对话

android - 在 android studio 中重命名可绘制图像?

android - Android 的 DUND 是否支持 DUN DT(又名拨号客户端又名数据终端又名 "dund --connect")

菜单无法在三星设备上打开的 Android 问题

java - android中的默认微调器样式

替换 fragment 时Android适合SystemWindows不起作用

android - 从广播短信接收器更新谷歌地图标记