页面嵌套怎么做呢,想做个底部可切换tab的demo,
类似android的activity + viewpager + 多个fragment应该怎么搞啊?求大佬解惑。
页面嵌套
赞
收藏 0
回答 3
待解决
相关问题
后台录像需要怎么做呢?
3969浏览 • 1回复 待解决
HarmonyOS 页面顶部statusbar和底部虚拟按键高度适配怎么做?
220浏览 • 1回复 待解决
HarmonyOS 全局监听屏幕或者window上边的点击, 该怎么做呢?
206浏览 • 1回复 待解决
在vue里怎么做环境的判断?
106浏览 • 1回复 待解决
fetch 怎么做超时处理?
395浏览 • 1回复 待解决
HarmonyOS 项目要做一个页面,页面中有多级tab的切换展示;如何做布局?
218浏览 • 1回复 待解决
请问怎么做MySQL的数据优化?
2177浏览 • 2回复 待解决
鸿蒙的OTA升级要怎么做
2852浏览 • 0回复 待解决
HarmonyOS 实现沉浸式全屏模式,全局设置所有页面方式怎么做?
347浏览 • 1回复 待解决
应用的配置文件“config.json”中添加注释怎么做呢
11276浏览 • 2回复 待解决
三表连表查询+groupby怎么做?
2044浏览 • 1回复 待解决
polarDB私有化部署怎么做?
3535浏览 • 1回复 待解决
Tab组件页面切换时,如何不显示中间过渡的tab页
376浏览 • 1回复 待解决
求助 很急arkts开发这种样式的怎么做?
2041浏览 • 1回复 待解决
HarmonyOS tab嵌套横向list,如何实现list滑动到最右边就自动触发tab的滑动切换?
195浏览 • 1回复 待解决
选择PolarDB实例接入方式,需要怎么做?
2735浏览 • 1回复 待解决
HarmonyOS webview加载h5页面点击拍照相册webview怎么做兼容
406浏览 • 1回复 待解决
HarmonyOS 整个app更换字体,怎么做最方便?
207浏览 • 1回复 待解决
HarmonyOS 能不能提供一个类似excel,可滑动表格的demo呢?
172浏览 • 1回复 待解决
MQTT 服务器 怎么做压力测试,求指导?
3703浏览 • 1回复 待解决
应用侧显示华为云mqtt数据是怎么做?
6948浏览 • 1回复 待解决
利用tabcontent来构建页面时,在各个tab之间来回切换时,如何每次切换都触发对应tab下面控件的数据请求?
211浏览 • 1回复 待解决
用ETS实现语音视频通话,应该怎么做?
3127浏览 • 1回复 待解决
Tab控件切换问题有哪些?
165浏览 • 1回复 待解决
HarmonyOS 输入框的文字,怎么做才可以再最左边显示?
357浏览 • 1回复 待解决
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:orientation="vertical">
<DirectionalLayout
ohos:id="$+id:dl_frame"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:weight="1"/>
<DirectionalLayout
ohos:background_element="transparent"
ohos:height="match_content"
ohos:width="match_parent"
ohos:orientation="horizontal">
<DirectionalLayout
ohos:id="$+id:listtenDL"
ohos:height="match_content"
ohos:width="match_content"
ohos:top_margin="20vp"
ohos:background_element="#ffffff"
ohos:weight="1">
<Text
ohos:height="match_content"
ohos:width="match_parent"
ohos:id="$+id:home"
ohos:bottom_margin="5vp"
ohos:text_color="$color:color_f3"
ohos:element_top="$media:shouye"
ohos:text_alignment="center"
ohos:layout_alignment="center"
ohos:text_size="15fp"
ohos:text="首页"/>
</DirectionalLayout>
<DirectionalLayout
ohos:id="$+id:classlyDL"
ohos:height="match_content"
ohos:width="match_content"
ohos:top_margin="20vp"
ohos:background_element="#fff"
ohos:weight="1">
<Text
ohos:id="$+id:classly"
ohos:height="match_content"
ohos:width="match_parent"
ohos:bottom_margin="5vp"
ohos:text_color="$color:color_d0"
ohos:element_top="$media:fenlei"
ohos:text_alignment="center"
ohos:layout_alignment="center"
ohos:text_size="15fp"
ohos:text="分类"/>
</DirectionalLayout>
<DirectionalLayout
ohos:id="$+id:communityDL"
ohos:height="match_content"
ohos:width="match_content"
ohos:top_margin="20vp"
ohos:background_element="#fff"
ohos:weight="1">
<Text
ohos:id="$+id:community"
ohos:height="match_content"
ohos:width="match_parent"
ohos:bottom_margin="5vp"
ohos:text_color="$color:color_d0"
ohos:element_top="$media:sq"
ohos:text_alignment="center"
ohos:text_size="15fp"
ohos:layout_alignment="center"
ohos:text="社区"/>
</DirectionalLayout>
<DirectionalLayout
ohos:id="$+id:shopingDL"
ohos:height="match_content"
ohos:width="match_content"
ohos:top_margin="20vp"
ohos:background_element="#fff"
ohos:weight="1">
<Text
ohos:id="$+id:shoping"
ohos:height="match_content"
ohos:width="match_parent"
ohos:bottom_margin="5vp"
ohos:text_color="$color:color_d0"
ohos:element_top="$media:gwc"
ohos:text_alignment="center"
ohos:layout_alignment="center"
ohos:text_size="15fp"
ohos:text="购物车"/>
</DirectionalLayout>
<DirectionalLayout
ohos:id="$+id:myDL"
ohos:height="match_content"
ohos:width="match_content"
ohos:top_margin="20vp"
ohos:background_element="#fff"
ohos:weight="1">
<Text
ohos:id="$+id:my"
ohos:height="match_content"
ohos:width="match_parent"
ohos:bottom_margin="5vp"
ohos:text_color="$color:color_d0"
ohos:element_top="$media:my"
ohos:text_alignment="center"
ohos:layout_alignment="center"
ohos:text_size="15fp"
ohos:text="个人"/>
</DirectionalLayout>
</DirectionalLayout>
</DirectionalLayout>
public class MainAbilitySlice extends AbilitySlice {
@BindView(value = ResourceTable.Id_dl_frame)
DirectionalLayout dl_frame;
@BindView(value = ResourceTable.Id_listtenDL)
DirectionalLayout listtenDL;
@BindView(value = ResourceTable.Id_classlyDL)
DirectionalLayout classlyDL;
@BindView(value = ResourceTable.Id_communityDL)
DirectionalLayout communityDL;
@BindView(value = ResourceTable.Id_shopingDL)
DirectionalLayout shopingDL;
@BindView(value = ResourceTable.Id_myDL)
DirectionalLayout myDL;
@BindView(value = ResourceTable.Id_home)
Text home;
@BindView(value = ResourceTable.Id_classly)
Text classly;
@BindView(value = ResourceTable.Id_community)
Text community;
@BindView(value = ResourceTable.Id_shoping)
Text shoping;
@BindView(value = ResourceTable.Id_my)
Text my;
@Override
public void onStart(Intent intent) {
super.onStart(intent);
super.setUIContent(ResourceTable.Layout_ability_main);
ButterKnife.bind(this);
//默认第一个
setUI(new HomeSlice(), home);
}
@OnClick({ResourceTable.Id_home, ResourceTable.Id_classly, ResourceTable.Id_shoping, ResourceTable.Id_community, ResourceTable.Id_my})
public void click(Component component) {
System.err.println(component.getId() + "::::::::::::::::::::::");
switch (component.getId()) {
case ResourceTable.Id_home:
setUI(new HomeSlice(), home);
break;
case ResourceTable.Id_classly:
setUI(new ClasslySlice(), classly);
break;
case ResourceTable.Id_shoping:
setUI(new ShopingSlice(), shoping);
break;
case ResourceTable.Id_community:
setUI(new CommunitySlice(), community);
break;
case ResourceTable.Id_my:
setUI(new MySlice(), my);
break;
}
}
public void setUI(Fraction fraction, Text textview) {
//清空文字颜色
setTextColor(textview);
dl_frame.removeAllComponents();
//加载界面
((FractionAbility) getAbility()).getFractionManager().startFractionScheduler().add(ResourceTable.Id_dl_frame, fraction).submit();
}
//单个Item切换
public void setTextColor(Text textview) {
ResourceManager resourceManager = getAbility().getResourceManager();
Resource resource;
PixelMapElement element;
try {
int color = resourceManager.getElement(ResourceTable.Color_color_d0).getColor();
int color2 = resourceManager.getElement(ResourceTable.Color_color_f3).getColor();
clearClick(color);//清除点击事件
textview.setTextColor(new Color(color2));
if (textview == home) {//首页
resource = resourceManager.getResource(ResourceTable.Media_home1);
element = new PixelMapElement(resource);
home.setAroundElements(null, element, null, null);
} else if (textview == classly) {//分类
resource = resourceManager.getResource(ResourceTable.Media_fenlei1);
element = new PixelMapElement(resource);
classly.setAroundElements(null, element, null, null);
} else if (textview == community) {//社区
resource = resourceManager.getResource(ResourceTable.Media_sq1);
element = new PixelMapElement(resource);
community.setAroundElements(null, element, null, null);
} else if (textview == shoping) {//购物车
resource = resourceManager.getResource(ResourceTable.Media_gwc1);
element = new PixelMapElement(resource);
shoping.setAroundElements(null, element, null, null);
} else if (textview == my) {//我的
resource = resourceManager.getResource(ResourceTable.Media_my1);
element = new PixelMapElement(resource);
my.setAroundElements(null, element, null, null);
}
} catch (Exception e) {
e.printStackTrace();
}
}
//清空点击事件
public void clearClick(int color1) {
ResourceManager resourceManager = getAbility().getResourceManager();
Resource resource;
PixelMapElement element;
try {
resource = resourceManager.getResource(ResourceTable.Media_home);
element = new PixelMapElement(resource);
home.setAroundElements(null, element, null, null);
home.setTextColor(new Color(color1));
resource = resourceManager.getResource(ResourceTable.Media_fenlei);
element = new PixelMapElement(resource);
classly.setAroundElements(null, element, null, null);
classly.setTextColor(new Color(color1));
resource = resourceManager.getResource(ResourceTable.Media_sq);
element = new PixelMapElement(resource);
community.setAroundElements(null, element, null, null);
community.setTextColor(new Color(color1));
resource = resourceManager.getResource(ResourceTable.Media_gwc);
element = new PixelMapElement(resource);
shoping.setAroundElements(null, element, null, null);
shoping.setTextColor(new Color(color1));
resource = resourceManager.getResource(ResourceTable.Media_my);
element = new PixelMapElement(resource);
my.setAroundElements(null, element, null, null);
my.setTextColor(new Color(color1));
} catch (Exception e) {
e.printStackTrace();
}
}
//回退拦截
@Override
protected void onBackPressed() {
//弹出提示框
CommonDialog commonDialog = new CommonDialog(getContext());
DirectionalLayout toastLayout = (DirectionalLayout) LayoutScatter.getInstance(getContext())
.parse(ResourceTable.Layout_layout_dialog, null, false);
commonDialog.setContentCustomComponent(toastLayout);
//退出应用
Button dialog_out = (Button)toastLayout.findComponentById(ResourceTable.Id_dialog_out);
dialog_out.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component component) {
commonDialog.hide();
terminateAbility();
}
});
//隐藏
Button dialog_hide = (Button)toastLayout.findComponentById(ResourceTable.Id_dialog_hide);
dialog_hide.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component component) {
commonDialog.hide();
}
});
//再听听
Button dialog_continue = (Button)toastLayout.findComponentById(ResourceTable.Id_dialog_continue);
dialog_continue.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component component) {
commonDialog.hide();
}
});
commonDialog.setSize(800,410);
commonDialog.setAlignment(LayoutAlignment.CENTER);
commonDialog.show();
}
@Override
public void onActive() {
super.onActive();
}
@Override
public void onForeground(Intent intent) {
super.onForeground(intent);
}
}
就这些就可以实现了,我的这个写的比较乱