2024年Android最全鸿蒙HarmonyOS APP开发入门3——组件(八 输入框组件 ),面试要怎么练

总结

【Android 详细知识点思维脑图(技能树)】

image

其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。

虽然 Android 没有前几年火热了,已经过去了会四大组件就能找到高薪职位的时代了。这只能说明 Android 中级以下的岗位饱和了,现在高级工程师还是比较缺少的,很多高级职位给的薪资真的特别高(钱多也不一定能找到合适的),所以努力让自己成为高级工程师才是最重要的。

这里附上上述的面试题相关的几十套字节跳动,京东,小米,腾讯、头条、阿里、美团等公司19年的面试题。把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节。

由于篇幅有限,这里以图片的形式给大家展示一小部分。

网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

设置Bubble
<TextField
 ...
 ohos:element\_cursor\_bubble="$graphic:ele\_cursor\_bubble" />

其中ele_cursor_bubble.xml

<?xml version="1.0" encoding="UTF-8" ?>
<shape xmlns:ohos="http://schemas.huawei.com/res/ohos"
 ohos:shape="rectangle">
    <corners
 ohos:radius="40"/>
    <solid
 ohos:color="#17a98e"/>
    <stroke
 ohos:color="#17a98e"
 ohos:width="10"/>
</shape>

设置bubble的效果

img

设置TextField的内边距
<TextField
 ...
 ohos:left\_padding="24vp"
 ohos:right\_padding="24vp"
 ohos:top\_padding="8vp"
 ohos:bottom\_padding="8vp"/>

设置TextField的多行显示
<TextField
 ...
 ohos:multiple\_lines="true"/>

设置TextField不可用状态

通过TextField的Enable属性来控制文本框是否可用,当设置成false后,文本框输入功能不可用。

textField.setEnabled(false);

响应焦点变化
textField.setFocusChangedListener((component, isFocused) -> {
    
    if (isFocused) { 
        // 获取到焦点
        ...
    } else { 
        // 失去焦点
        ...
    }
});

设置基线
<TextField
 ...
 ohos:basement="#ff0000" />

设置基线的效果

img

实践运用

实践1

当点击登录按钮,将会出现错误提示,同时将会改变TextField的状态。

演示TextField错误提示效果
点击放大

  • ability_text_field.xml代码示例:
<?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="#FF000000"
 ohos:orientation="vertical">

    <StackLayout
 ohos:top\_margin="60vp"
 ohos:width="match\_parent"
 ohos:height="match\_content"
 ohos:layout\_alignment="center">
        <TextField
 ohos:id="$+id:name\_textField"
 ohos:width="600vp"
 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="vertical\_center"
 ohos:background\_element="$graphic:background\_text\_field"
 ohos:hint="Enter phone number or email" />

        <Text
 ohos:visibility="hide"
 ohos:id="$+id:error\_tip\_text"
 ohos:width="match\_content"
 ohos:height="match\_content"
 ohos:top\_padding="8vp"
 ohos:bottom\_padding="8vp"
 ohos:right\_margin="20vp"
 ohos:text="Incorrect account or password"
 ohos:text\_size="18fp"
 ohos:text\_color="red"
 ohos:layout\_alignment="right"/>
    </StackLayout>

    <TextField
 ohos:top\_margin="40vp"
 ohos:id="$+id:password\_text\_field"
 ohos:width="600vp"
 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="vertical\_center"
 ohos:background\_element="$graphic:background\_text\_field"
 ohos:hint="Enter password" />

    <Button
 ohos:top\_margin="40vp"
 ohos:id="$+id:ensure\_button"
 ohos:width="120vp"
 ohos:height="35vp"
 ohos:background\_element="$graphic:background\_btn"
 ohos:text="Log in"
 ohos:text\_size="20fp"
 ohos:layout\_alignment="horizontal\_center"/>

</DirectionalLayout>

background_text_field.xml代码示例:

<?xml version="1.0" encoding="UTF-8" ?>
<shape xmlns:ohos="http://schemas.huawei.com/res/ohos"
 ohos:shape="rectangle">
    <corners
 ohos:radius="40"/>
    <solid
 ohos:color="white"/>
    <stroke
 ohos:color="black"
 ohos:width="6"/>
</shape>

background_btn.xml代码示例:

<?xml version="1.0" encoding="UTF-8" ?>
<shape xmlns:ohos="http://schemas.huawei.com/res/ohos"
 ohos:shape="rectangle">
    <corners
 ohos:radius="35"/>
    <solid
 ohos:color="white"/>
</shape>

  • Java代码示例:
// 当点击登录,改变相应组件的样式
Button button = (Button) findComponentById(ResourceTable.Id\_ensure\_button);
button.setClickedListener((component -> {
    // 显示错误提示的Text
    Text text = (Text) findComponentById(ResourceTable.Id\_error\_tip\_text);
    text.setVisibility(Component.VISIBLE);

    // 显示TextField错误状态下的样式
    ShapeElement errorElement = new ShapeElement(this, ResourceTable.Graphic\_background\_text\_field\_error);
    TextField textField = (TextField) findComponentById(ResourceTable.Id\_name\_textField);
    textField.setBackground(errorElement);

    // TextField失去焦点
    textField.clearFocus();
}));

其中background_text_field_error.xml代码示例:

<?xml version="1.0" encoding="UTF-8" ?>
<shape xmlns:ohos="http://schemas.huawei.com/res/ohos"
 ohos:shape="rectangle">
    <corners
 ohos:radius="40"/>
    <solid
 ohos:color="gray"/>
    <stroke
 ohos:color="#E74C3C"
 ohos:width="6"/>
</shape>

实践2

获取文本输入框中的内容并进行吐司提示

xml文件

<?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:background\_element="#F2F2F2" 
 ohos:orientation="vertical" >
    <TextField 
 ohos:id="$+id:text"
 ohos:height="50vp" 
 ohos:width="319vp"
 ohos:background\_element="#FFFFFF" 
 ohos:hint="请输入信息" 
 ohos:hint\_color="#999999" 
 ohos:layout\_alignment="horizontal\_center" 
 ohos:text\_alignment="center" 
 ohos:text\_size="17fp" 
 ohos:top\_margin="100vp"/>
    <Button 
 ohos:id="$+id:but" 
 ohos:height="47vp" 


### 尾声

面试成功其实都是必然发生的事情,因为在此之前我做足了充分的准备工作,不单单是纯粹的刷题,更多的还会去刷一些Android核心架构进阶知识点,**比如:JVM、高并发、多线程、缓存、热修复设计、插件化框架解读、组件化框架设计、图片加载框架、网络、设计模式、设计思想与代码质量优化、程序性能优化、开发效率优化、设计模式、负载均衡、算法、数据结构、高级UI晋升、Framework内核解析、Android组件内核等。**
![](https://img-blog.csdnimg.cn/img_convert/69c7b21382e79a50923e2d257df1bfd4.webp?x-oss-process=image/format,png)

不仅有学习文档,视频+笔记提高学习效率,还能稳固你的知识,形成良好的系统的知识体系。这里,笔者分享一份从架构哲学的层面来剖析的视频及资料分享给大家梳理了多年的架构经验,筹备近6个月最新录制的,相信这份视频能给你带来不一样的启发、收获。

![](https://img-blog.csdnimg.cn/img_convert/bf376877601224f71e53dd47ff1ffa22.webp?x-oss-process=image/format,png)

##### Android进阶学习资料库

一共十个专题,包括了Android进阶所有学习资料,Android进阶视频,Flutter,java基础,kotlin,NDK模块,计算机网络,数据结构与算法,微信小程序,面试题解析,framework源码!

![image](https://img-blog.csdnimg.cn/img_convert/c3be0c0645498d82a3132ba54ede0e09.webp?x-oss-process=image/format,png)

##### 大厂面试真题

PS:之前因为秋招收集的二十套一二线互联网公司Android面试真题 (含BAT、小米、华为、美团、滴滴)和我自己整理Android复习笔记(包含Android基础知识点、Android扩展知识点、Android源码解析、设计模式汇总、Gradle知识点、常见算法题汇总。)

![](https://img-blog.csdnimg.cn/img_convert/3a4ecc2196f8e1b6d4d9668a500d0cc6.webp?x-oss-process=image/format,png)

**《2017-2021字节跳动Android面试历年真题解析》**

![](https://img-blog.csdnimg.cn/img_convert/40811fcf4f8f6530c545e33be998948d.webp?x-oss-process=image/format,png)



**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化学习资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618156601)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

片转存中...(img-4jkrJf9I-1715640816583)]

**《2017-2021字节跳动Android面试历年真题解析》**

[外链图片转存中...(img-40yO88kO-1715640816583)]



**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化学习资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618156601)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

  • 17
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值