页面嵌套怎么做呢,想做个底部可切换tab的demo,
类似android的activity + viewpager + 多个fragment应该怎么搞啊?求大佬解惑。
页面嵌套
赞
收藏 0
回答 3
待解决
相关问题
后台录像需要怎么做呢?
4103浏览 • 1回复 待解决
HarmonyOS 页面顶部statusbar和底部虚拟按键高度适配怎么做?
412浏览 • 1回复 待解决
HarmonyOS 全局监听屏幕或者window上边的点击, 该怎么做呢?
327浏览 • 1回复 待解决
#鸿蒙通关秘籍#想做好管理自定义组件的代码复用性,怎么做
123浏览 • 1回复 待解决
在vue里怎么做环境的判断?
213浏览 • 1回复 待解决
fetch 怎么做超时处理?
524浏览 • 1回复 待解决
HarmonyOS TabContent tab页面切换的时候TabContent 里的页面怎么监听切换到当前页面了
37浏览 • 1回复 待解决
鸿蒙的OTA升级要怎么做
2983浏览 • 0回复 待解决
请问怎么做MySQL的数据优化?
2298浏览 • 2回复 待解决
HarmonyOS 实现沉浸式全屏模式,全局设置所有页面方式怎么做?
438浏览 • 1回复 待解决
应用的配置文件“config.json”中添加注释怎么做呢
11487浏览 • 2回复 待解决
HarmonyOS 项目要做一个页面,页面中有多级tab的切换展示;如何做布局?
338浏览 • 1回复 待解决
三表连表查询+groupby怎么做?
2118浏览 • 1回复 待解决
polarDB私有化部署怎么做?
3686浏览 • 1回复 待解决
求助 很急arkts开发这种样式的怎么做?
2095浏览 • 1回复 待解决
选择PolarDB实例接入方式,需要怎么做?
2836浏览 • 1回复 待解决
HarmonyOS 页面底部留白是否可填充,使页面全屏
37浏览 • 1回复 待解决
Tab组件页面切换时,如何不显示中间过渡的tab页
517浏览 • 1回复 待解决
#鸿蒙通关秘籍#请教一下,ArkUI页面路由应该怎么做,有人能帮帮吗?
166浏览 • 1回复 待解决
HarmonyOS webview加载h5页面点击拍照相册webview怎么做兼容
559浏览 • 1回复 待解决
#鸿蒙通关秘籍#在HarmonyOS应用中,状态管理是怎么做的?
156浏览 • 1回复 待解决
HarmonyOS tab嵌套横向list,如何实现list滑动到最右边就自动触发tab的滑动切换?
301浏览 • 1回复 待解决
HarmonyOS 整个app更换字体,怎么做最方便?
351浏览 • 1回复 待解决
应用侧显示华为云mqtt数据是怎么做?
7050浏览 • 1回复 待解决
MQTT 服务器 怎么做压力测试,求指导?
3901浏览 • 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);
}
}
就这些就可以实现了,我的这个写的比较乱