gpt4 book ai didi

android - android :layout_above ="@android:id/tabs"? 的等效代码是什么

转载 作者:太空宇宙 更新时间:2023-11-03 13:06:14 25 4
gpt4 key购买 nike

我创建了一个 TabWidget

TabWidget tabWidget = new TabWidget(this);
tabWidget.setId(android.R.id.tabs);

和一个框架布局

FrameLayout frameLayout = new FrameLayout(this);
frameLayout.setId(android.R.id.tabcontent);

如何在标签上方制作框架布局?

**what is the equivalent code to "android:layout_above="@android:id/tabs"**

编辑

我正在处理这段代码,它正确吗?

TabHost tabHost = new TabHost(this);
tabHost.setLayoutParams(
new RelativeLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT,1));
TabWidget tabWidget = new TabWidget(this);
tabWidget.setId(android.R.id.tabs);

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(width, height);
lp.addRule(RelativeLayout.ABOVE, R.id.tabcontent);
tabWidget.setLayoutParams(lp);

tabHost.addView(tabWidget);
FrameLayout frameLayout = new FrameLayout(this);
frameLayout.setId(android.R.id.tabcontent);
frameLayout.setPadding(0, 55, 0, 0);
tabHost.addView(frameLayout, new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tabHost.setup();

最佳答案

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(width, height);
lp.addRule(RelativeLayout.ABOVE, R.id.tabcontent);
tabWidget.setLayoutParams(lp);

关于android - android :layout_above ="@android:id/tabs"? 的等效代码是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4229479/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com