征文#鸿蒙卡片-物联网DTU污水液位计卡片查看详情:https://bbs.elecfans.com/jishu_2106011_1_1.html5、HarmonyOSAPP开发-JS时钟练习尝试查看详情:https://bbs.elecfans.com/jishu_2104144_1_1.html
2021-06-29 11:30
一、技术相关项目名称:jltf-SettingsAbilitty项目语言:js体验模板: SettingsAbilitty工具:deveco studio二、效果如下:三、开发体验过程第一步 建立项目新建一个js的应用项目,直接点击next进行下一步第二步修改部分代码主要部分:Hml部分 {{ title }} {{ list_group.value }} {{ list_group.value }} {{ tv_img_text }} Css部分.all { flex-direction: column; background-color: #f1f3f5;}.list_container { flex-direction: column;}.container_tv { display: none;}.content { justify-content: center;}@MEDIA screen and (device-type: tv) { .bar_container {display: none; } .title_container {width: 100%;text-align: left;margin: 24px 45px;height: 100px; } .title {font-weight: bold;font-size: 45px; } /** left */ .list_container {display: none; } .container_tv {display: flex;flex-direction: column;background-image: url("/common/Wallpaper.png"); } .list_tv_container {width: 100%; } .list_tv {margin-left: 24px; } .wearable_item {display: none; } .content_tv {height: 48px;background-color: #33f1f3f5;border-radius: 12px;margin: 6px 0;padding-left: 12px; } .content_tv_text {font-size: 18px;color: #E5FFFFFF; } /** right */ .content_img {flex-direction: column;justify-content: flex-start;align-items: center; } .img_box {margin-top: 76px;background-color: #808080;width: 180px;height: 180px; } .img_img {object-fit: contain;width: 180px;height: 180px; } .text_box {width: 100%;margin-top: 20px;justify-content: center; } .img_text {width: 280px;font-size: 18px;color: #99FFFFFF;text-align: center; }}@media screen and (device-type: wearable) { .bar_container {display: none; } .title_container {justify-content: center;height: 20%; } .title {font-size: 19px;font-weight: bold; } .content_img {display: none; } .list_container {display: none; } .container_tv {display: flex;flex-direction: column;background-color: black; } .list_tv_container {width: 100%;justify-content: center; } .list_tv {width: 90%; } .sub_item {justify-content: center;align-items: center; } .content_tv {justify-content: center; } .content_tv_text {display: none; } .wearable_item {flex-direction: column;align-items: center;justify-content: center; } .wearable_item_img {height: 5px; } .wearable_item_text {height: 48px;padding-bottom: 6px;justify-content: center; } .wearable_item_text_content {font-size: 19px;text-align: center; }}Js部分:const TAG = '[fragment_main]';export default { data: {title: "",array: [[1, 0], [1, 1], [1, 2], [2, 2], [2, 2], [2, 3], [3, 3], [3, 5]],list: [],tv_img_add: "common/profile.png",tv_img_text: "",file_data: [{ "image_add": "common/profile.png",},{ "image_add": "common/ic.png",},{ "image_add": "common/more.png",},{ "image_add": "common/add64.png",},{ "image_add": "common/add64.png",},{ "image_add": "common/add64.png",},{ "image_add": "common/add64.png",},{ "image_add": "common/add64.png",}] }, onInit() {this.title = this.$t('strings.title');this.list = [];this.tv_img_text = this.$t('strings.img_text_0');var str = 'strings.Setting';for (var i = 0; i < this.array.length; i++) {var resource = str + i;var dataItem = { value: this.$t(resource)};this.list.push(dataItem);} }, changeList($idx) {console.log(TAG + $idx);this.tv_img_add = this.file_data[$idx].image_add;this.tv_img_text = this.$t('strings.img_text_' + $idx);this.$element($idx).focus({focus: true}); }}第三步登录你的账号然后启动模拟器即可实现效果完整代码地址:https://gitee.com/jltfcloudcn/jump_to/tree/master/SettingsAbility附件:
2021-08-09 09:40
`显示效果: 上下拖动改变选中的值 布局中的代码:<?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"> <TimePickerohos:id="$+id:time_picker"ohos:height="match_parent"ohos:width="match_parent"ohos:normal_text_color="#007DFF"ohos:normal_text_size="25fp"ohos:operated_text_color="#FF9912"ohos:shader_color="#00BFFF"/></DirectionalLayout>Slice文件中package com.example.jltftiyan5.slice;import com.example.jltftiyan5.ResourceTable;import ohos.aafwk.ability.AbilitySlice;import ohos.aafwk.content.Intent;import ohos.agp.components.TimePicker;public class MainAbilitySlice extends AbilitySlice { @Override public void onStart(Intent intent) {super.onStart(intent);super.setUIContent(ResourceTable.Layout_ability_main);TimePicker timePicker = (TimePicker) findComponentById(ResourceTable.Id_time_picker);int hour = timePicker.getHour();int minute = timePicker.getMinute();int second = timePicker.getSecond();timePicker.setHour(19);timePicker.setMinute(18);timePicker.setSecond(12);timePicker.setTimeChangedListener(new TimePicker.TimeChangedListener() {@Overridepublic void onTimeChanged(TimePicker timePicker, int hour, int minute, int second) {}}); } @Override public void onActive() {super.onActive(); } @Override public void onForeground(Intent intent) {super.onForeground(intent); }}完整代码下载地址:https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_TimePicker_component`
2021-03-20 12:26
`Switch是切换单个设置开/关两种状态的组件。我们体验效果如下。显示效果: 滑动按钮 代码如下:布局中<?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"> <Switchohos:id="$+id:btn_switch"ohos:height="30vp"ohos:width="60vp"ohos:top_margin="40px"ohos:left_margin="400px"ohos:text_state_off="OFF"ohos:text_state_on="ON"/></DirectionalLayout> 完整源码地址:https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_switch_component`
2021-03-24 10:12
`RoundProgressBar用于显示环形进度 代码如下<?xml version="1.0" encoding="utf-8"?><DirectionalLayoutxmlns:ohos="http://schemas.huawei.com/res/ohos"ohos:height="match_parent"ohos:width="match_parent"ohos:orientation="vertical"ohos:background_element="#FF000000"> <DirectionalLayoutohos:height="0px"ohos:width="match_parent"ohos:weight="1"><RoundProgressBarohos:id="$+id:round_progress_bar"ohos:height="200vp"ohos:width="200vp"ohos:progress_width="10vp"ohos:progress="20"ohos:progress_color="#47CC47"ohos:layout_alignment="center"/> </DirectionalLayout> <DirectionalLayoutohos:height="0px"ohos:width="match_parent"ohos:weight="1"><RoundProgressBarohos:height="200vp"ohos:width="200vp"ohos:progress_width="10vp"ohos:progress="20"ohos:progress_color="#47CC47"ohos:start_angle="45"ohos:max_angle="270"ohos:progress_hint_text="加载中。。。"ohos:progress_hint_text_color="#007DFF"ohos:layout_alignment="center" /> </DirectionalLayout></DirectionalLayout>完整代码地址:https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_RoundProgressBar_component`
2021-03-29 14:29
`ProgressBar用于显示内容或操作的进度。下面将进行对该组件简单的操作,通过添加不同的属性展示出不同的样式效果。如下:效果显示: 布局中的代码<?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" ohos:background_element="#FF5A5858"><Text ohos:height="match_content" ohos:width="match_content" ohos:text="创建ProgressBar效果" ohos:text_size="22fp" ohos:text_color="red"/> <ProgressBarohos:progress_width="10vp"ohos:height="60vp"ohos:width="800px"ohos:max="100"ohos:min="0"ohos:progress="60"/> <Textohos:height="match_content"ohos:width="match_content"ohos:text="垂直ProgressBar效果。"ohos:text_size="22fp"ohos:text_color="red"/> <Textohos:height="match_content"ohos:width="match_content"ohos:text="设置ProgressBar颜色效果。"ohos:text_size="22fp"ohos:text_color="red"/> <ProgressBarohos:orientation="vertical"ohos:top_margin="20vp"ohos:height="150vp"ohos:width="60vp"ohos:progress_width="10vp"ohos:max="100"ohos:min="0"ohos:progress="60"ohos:background_instruct_element="#FFFFFF"ohos:progress_element="#FF9900"/> <Textohos:height="match_content"ohos:width="match_content"ohos:text="添加分割线效果。"ohos:text_size="22fp"ohos:text_color="red"/> <ProgressBarohos:progress_width="10vp"ohos:height="60vp"ohos:width="800px"ohos:max="100"ohos:min="0"ohos:progress="40"ohos:divider_lines_enabled="true"ohos:divider_lines_number="5"/> <Textohos:height="match_content"ohos:width="match_content"ohos:text="设置提示文字效果。"ohos:text_size="22fp"ohos:text_color="red"/> <ProgressBarohos:progress_width="10vp"ohos:height="60vp"ohos:width="800px"ohos:max="100"ohos:min="0"ohos:progress="40"ohos:divider_lines_enabled="true"ohos:divider_lines_number="5"ohos:progress_hint_text="40%"ohos:progress_hint_text_color="#FFCC99" /></DirectionalLayout>完整代码地址:https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_progressBar_component`
2021-03-29 14:31
`这里敲了一个简单的案例,我们可以通过使用DatePicker来实现一个日期选择器的创建,在xml文件中使用DatePicker标签就可以创建出一个日期选择器来。 我们可以通过DatePicker默认选择当前时间,也可以设置当前的时间,我们还可以获取选择器里面的时间进行展示等操作。 可以设置最小日期值和最大日期值。 这里可以通过year_fixed,month_fixed,day_fixed对年月日进行一个值的固定。 也可以通过一些相关属性进行字体,背景等美化,如下图所示: 完成代码下载地址:https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_DatePicker_component`
2021-03-20 12:40
`ScrollView是一种带滚动功能的组件,它采用滑动的方式在有限的区域内显示更多的内容。这里我做了一个小案例,在ScrollView里面套ScrollView,当然我们也可以使用DirectionalLayout中的horizontal或者vertical属性控制图片滑动的方向这里使用ScrollView可以很方便的展示跟多的内容。 <?xml version="1.0" encoding="utf-8"?><DirectionalLayoutxmlns:ohos="http://schemas.huawei.com/res/ohos"ohos:height="match_parent"ohos:width="match_parent"ohos:orientation="vertical"> <DirectionalLayoutohos:height="1800px"ohos:width="match_parent"ohos:orientation="vertical"><ScrollViewohos:height="match_parent"ohos:width="match_parent"><DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"><Imageohos:height="600px"ohos:width="match_parent"ohos:image_src="$media:tupian1"/> </DirectionalLayout> <DirectionalLayoutohos:height="80px"ohos:width="match_parent"><Textohos:height="match_parent"ohos:width="match_parent"ohos:text="颜色展示"ohos:text_size="18fp"/> </DirectionalLayout> <DirectionalLayoutohos:height="700px"ohos:width="match_parent"ohos:orientation="vertical"><ScrollViewohos:height="match_parent"ohos:width="match_parent"><DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"><Textohos:height="80px"ohos:width="match_parent"ohos:text="红色"ohos:text_size="18fp"/><Imageohos:height="match_content"ohos:width="match_parent"ohos:image_src="$media:red"/> </DirectionalLayout> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"><Textohos:height="80px"ohos:width="match_parent"ohos:text="蓝色"ohos:text_size="18fp"/><Imageohos:height="match_content"ohos:width="match_parent"ohos:image_src="$media:blue"/> </DirectionalLayout> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"><Textohos:height="80px"ohos:width="match_parent"ohos:text="黄色"ohos:text_size="18fp"/><Imageohos:height="match_content"ohos:width="match_parent"ohos:image_src="$media:yellow"/> </DirectionalLayout> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"><Textohos:height="80px"ohos:width="match_parent"ohos:text="粉色"ohos:text_size="18fp"/><Imageohos:height="match_content"ohos:width="match_parent"ohos:image_src="$media:pink"/> </DirectionalLayout> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"><Textohos:height="80px"ohos:width="match_parent"ohos:text="绿色"ohos:text_size="18fp"/><Imageohos:height="match_content"ohos:width="match_parent"ohos:image_src="$media:grenn"/> </DirectionalLayout></DirectionalLayout></ScrollView> </DirectionalLayout> <DirectionalLayoutohos:height="80px"ohos:width="match_parent"><Textohos:height="match_parent"ohos:width="match_parent"ohos:text="图片展示"ohos:text_size="18fp"/> </DirectionalLayout> <DirectionalLayoutohos:height="500px"ohos:width="match_parent"ohos:orientation="vertical"><ScrollViewohos:height="match_parent"ohos:width="match_parent"><DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"> <Imageohos:height="match_parent"ohos:width="match_parent"ohos:image_src="$media:fengjing"/> <Imageohos:height="match_parent"ohos:width="match_parent"ohos:image_src="$media:mao"/> <Imageohos:height="match_parent"ohos:width="match_parent"ohos:image_src="$media:gou"/></DirectionalLayout></ScrollView> </DirectionalLayout></DirectionalLayout></ScrollView> </DirectionalLayout></DirectionalLayout> 代码如下: <?xml version="1.0" encoding="utf-8"?><DirectionalLayoutxmlns:ohos="http://schemas.huawei.com/res/ohos"ohos:height="match_parent"ohos:width="match_parent"ohos:orientation="vertical"> <DirectionalLayoutohos:height="1800px"ohos:width="match_parent"ohos:orientation="vertical"><ScrollViewohos:height="match_parent"ohos:width="match_parent"><DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"><Imageohos:height="600px"ohos:width="match_parent"ohos:image_src="$media:tupian1"/> </DirectionalLayout> <DirectionalLayoutohos:height="80px"ohos:width="match_parent"><Textohos:height="match_parent"ohos:width="match_parent"ohos:text="颜色展示"ohos:text_size="18fp"/> </DirectionalLayout> <DirectionalLayoutohos:height="700px"ohos:width="match_parent"ohos:orientation="vertical"><ScrollViewohos:height="match_parent"ohos:width="match_parent"><DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"><Textohos:height="80px"ohos:width="match_parent"ohos:text="红色"ohos:text_size="18fp"/><Imageohos:height="match_content"ohos:width="match_parent"ohos:image_src="$media:red"/> </DirectionalLayout> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"><Textohos:height="80px"ohos:width="match_parent"ohos:text="蓝色"ohos:text_size="18fp"/><Imageohos:height="match_content"ohos:width="match_parent"ohos:image_src="$media:blue"/> </DirectionalLayout> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"><Textohos:height="80px"ohos:width="match_parent"ohos:text="黄色"ohos:text_size="18fp"/><Imageohos:height="match_content"ohos:width="match_parent"ohos:image_src="$media:yellow"/> </DirectionalLayout> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"><Textohos:height="80px"ohos:width="match_parent"ohos:text="粉色"ohos:text_size="18fp"/><Imageohos:height="match_content"ohos:width="match_parent"ohos:image_src="$media:pink"/> </DirectionalLayout> <DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"><Textohos:height="80px"ohos:width="match_parent"ohos:text="绿色"ohos:text_size="18fp"/><Imageohos:height="match_content"ohos:width="match_parent"ohos:image_src="$media:grenn"/> </DirectionalLayout></DirectionalLayout></ScrollView> </DirectionalLayout> <DirectionalLayoutohos:height="80px"ohos:width="match_parent"><Textohos:height="match_parent"ohos:width="match_parent"ohos:text="图片展示"ohos:text_size="18fp"/> </DirectionalLayout> <DirectionalLayoutohos:height="500px"ohos:width="match_parent"ohos:orientation="vertical"><ScrollViewohos:height="match_parent"ohos:width="match_parent"><DirectionalLayoutohos:height="match_content"ohos:width="match_parent"ohos:orientation="vertical"> <Imageohos:height="match_parent"ohos:width="match_parent"ohos:image_src="$media:fengjing"/> <Imageohos:height="match_parent"ohos:width="match_parent"ohos:image_src="$media:mao"/> <Imageohos:height="match_parent"ohos:width="match_parent"ohos:image_src="$media:gou"/></DirectionalLayout></ScrollView> </DirectionalLayout></DirectionalLayout></ScrollView> </DirectionalLayout></DirectionalLayout>完整代码地址:https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_ScrollView_component`
2021-03-27 11:44
一、基本情况具备JS与JAVA的入门级知识,初次接触HarmonyOS,学习时间一周以内。二、学习教程https://developer.huawei.com/con
2021-06-16 15:45
`TextField提供了一种文本输入框。下面会通过一个案例给大家展示一下这个组件。显示效果: 代码如下:Slice文件中package com.example.jltftiyan3.slice;import com.example.jltftiyan3.ResourceTable;import ohos.aafwk.ability.AbilitySlice;import ohos.aafwk.content.Intent;import ohos.agp.components.Button;import ohos.agp.components.Component;import ohos.agp.components.Text;import ohos.agp.components.TextField;import ohos.agp.components.element.ShapeElement;public class MainAbilitySlice extends AbilitySlice { @Override public void onStart(Intent intent) {super.onStart(intent);super.setUIContent(ResourceTable.Layout_ability_main); } @Override public void onActive() {super.onActive(); } @Override public void onForeground(Intent intent) {super.onForeground(intent); }}布局中的代码:<?xml version="1.0" encoding="utf-8"?><DirectionalLayout xmlns:ohos="http://schemas.huawei.com/res/ohos" ohos:width="match_parent" ohos:height="match_parent" ohos:background_element="#FFC9C3C3" ohos:orientation="vertical"> <StackLayoutohos:top_margin="60vp"ohos:width="match_parent"ohos:height="match_content"ohos:layout_alignment="center"><TextFieldohos:id="$+id:name_textField"ohos:width="1000px"ohos:height="match_content"ohos:multiple_lines="false"ohos:left_padding="24vp"ohos:right_padding="24vp"ohos:top_padding="8vp"ohos:bottom_padding="8vp"ohos:min_height="44vp"ohos:text_size="18fp"ohos:layout_alignment="center"ohos:text_alignment="center_vertical"ohos:background_element="$graphic:jltfbackground_text_field"ohos:hint="请输入账号" /> </StackLayout> <TextFieldohos:top_margin="40vp"ohos:id="$+id:password_text_field"ohos:width="1000px"ohos:height="match_content"ohos:multiple_lines="false"ohos:left_padding="24vp"ohos:right_padding="24vp"ohos:top_padding="8vp"ohos:bottom_padding="8vp"ohos:min_height="44vp"ohos:text_size="18fp"ohos:layout_alignment="center"ohos:text_alignment="center_vertical"ohos:background_element="$graphic:jltfbackground_text_field"ohos:hint="请输入密码" /> <Buttonohos:top_margin="40vp"ohos:id="$+id:ensure_button"ohos:width="120vp"ohos:height="35vp"ohos:background_element="$graphic:jltfbackground_btn"ohos:text="Log in"ohos:text_size="20fp"ohos:layout_alignment="horizontal_center"/></DirectionalLayout> 完整代码包地址:https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_TextField_component`
2021-03-15 18:54