2024年Android最新Android-第一节基础知识及LinearLayout(线性布局),2024年最新学生会面试有趣的选择题

面试复习笔记:

这份资料我从春招开始,就会将各博客、论坛。网站上等优质的Android开发中高级面试题收集起来,然后全网寻找最优的解答方案。每一道面试题都是百分百的大厂面经真题+最优解答。包知识脉络 + 诸多细节。
节省大家在网上搜索资料的时间来学习,也可以分享给身边好友一起学习。

《960页Android开发笔记》

《1307页Android开发面试宝典》

包含了腾讯、百度、小米、阿里、乐视、美团、58、猎豹、360、新浪、搜狐等一线互联网公司面试被问到的题目。熟悉本文中列出的知识点会大大增加通过前两轮技术面试的几率。

《507页Android开发相关源码解析》

只要是程序员,不管是Java还是Android,如果不去阅读源码,只看API文档,那就只是停留于皮毛,这对我们知识体系的建立和完备以及实战技术的提升都是不利的。

真正最能锻炼能力的便是直接去阅读源码,不仅限于阅读各大系统源码,还包括各种优秀的开源库。

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

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

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

android:layout_marginBottom=“10dp”

android:layout_marginLeft=“10dp”

android:layout_marginRight=“10dp”

1.3控件的内边距


统一设置上下左右内边距:

android:padding=“5dp”

各自设置内边距:

android:paddingTop=“5dp”

android:paddingBottom=“5dp”

android:paddingLeft=“5dp”

android:paddingRight=“5dp”

2.线性布局(Linear Layout)

====================================================================================

LinearLayout 核心属性:

​ (1) android:orientation:两个属性值:“vertical” 垂直 “horizontal”水平

​ (2) android:layout_weight 将父控件的剩余空间按照设置的权重比例再分配

2.1示例:


在这里插入图片描述

<LinearLayout

android:id=“@+id/linearLayout”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:orientation=“horizontal”

app:layout_constraintEnd_toEndOf=“parent”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toTopOf=“parent”>

<Button

android:id=“@+id/button1”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“button1”>

<Button

android:id=“@+id/button2”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“button2”>

<Button

android:id=“@+id/button3”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“button3”>

2.2微信界面实战


在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

xmlns:app=“http://schemas.android.com/apk/res-auto”

xmlns:tools=“http://schemas.android.com/tools”

android:layout_width=“match_parent”

android:orientation=“vertical”

android:layout_height=“match_parent”

tools:context=“.MainActivity”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“×”

android:textSize=“50dp”

android:layout_marginLeft=“5dp”/>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“20dp”

android:layout_marginTop=“5dp”

android:text=“微信号/QQ/邮箱登录”

android:textColor=“@color/black”

android:textSize=“30dp”/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_marginTop=“30dp”>

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“1”

android:layout_marginTop=“6dp”

android:orientation=“horizontal”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“25dp”

android:text=“账号”

android:textColor=“@color/black”

android:textSize=“25dp” />

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“0”>

<EditText

android:layout_width=“wrap_content”

android:layout_height=“match_parent”

android:text="请填写微信号/QQ号/邮箱 "/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“45dp”

android:layout_marginTop=“10dp”

android:orientation=“horizontal”>

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“1”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“25dp”

android:text=“密码”

android:textColor=“@color/black”

android:textSize=“25dp” />

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“0”>

<EditText

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text="请填写密码 "/>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“用手机号登录”

android:layout_marginTop=“20dp”

android:layout_marginLeft=“25dp”

android:textSize=“20dp”

android:textColor=“@color/purple_500”/>

<Button

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:text=“登录”

android:textSize=“30dp”

android:layout_marginTop=“30dp”

/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_marginTop=“150dp”

android:orientation=“horizontal”>

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“2”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“找回密码”

android:layout_marginLeft=“80dp”

android:textColor=“@color/purple_500”

android:textSize=“15dp” />

<LinearLayout

android:layout_width=“122dp”

android:layout_height=“wrap_content”

android:layout_weight=“7”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“紧急冻结”

android:layout_marginLeft=“40dp”

android:textColor=“@color/purple_500”

android:textSize=“15dp” />

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“70”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“微信安全中心”

android:textColor=“@color/purple_500”/>

总结

首先是感觉自己的基础还是不够吧,大厂好像都喜欢问这些底层原理。

另外一部分原因在于资料也还没有看完,一面时凭借那份资料考前突击恶补个几天居然也能轻松应对(在这里还是要感谢那份资料,真的牛),于是自我感觉良好,资料就没有怎么深究下去了。

之前的准备只涉及了Java、Android、计网、数据结构与算法这些方面,面对面试官对其他基础课程的考察显得捉襟见肘。

下一步还是要查漏补缺,进行针对性复习。

最后的最后,那套资料这次一定要全部看完,是真的太全面了,各个知识点都涵盖了,几乎我面试遇到的所有问题的知识点这里面都有!希望大家不要犯和我一样的错误呀!!!一定要看完!

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

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

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

droid、计网、数据结构与算法这些方面,面对面试官对其他基础课程的考察显得捉襟见肘。

下一步还是要查漏补缺,进行针对性复习。

最后的最后,那套资料这次一定要全部看完,是真的太全面了,各个知识点都涵盖了,几乎我面试遇到的所有问题的知识点这里面都有!希望大家不要犯和我一样的错误呀!!!一定要看完!
[外链图片转存中…(img-LZiy9OBs-1715653869758)]

[外链图片转存中…(img-gmW2r9Vy-1715653869759)]

[外链图片转存中…(img-DXVIe7hq-1715653869759)]

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

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

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

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1.省,市,区三级关联 2.地址数据本地化 3.自定义对话框 4.支付从xml文件,或对象文件加载 部分代码: package com.demo.selector; import java.io.InputStream; import com.address.selector.City; import com.address.selector.Country; import com.address.selector.Province; import com.address.selector.Region; import com.demo.address.R; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; import android.widget.AdapterView.OnItemSelectedListener; public class AddressSelectorDialog extends BaseDialog { /**省类型*/ private static final int INDEX_PROVINCE = 1; /**城市类型*/ private static final int INDEX_CITY = 2; /**区县类型*/ private static final int INDEX_REGION = 3; private static Country china = null; private Spinner spnProvince = null; private Spinner spnCity = null; private Spinner spnRegion = null; private ArrayAdapter dptProvince = null; private ArrayAdapter dptCity = null; private ArrayAdapter dptRegion = null; private SpinnerSelectedListener proListener = new SpinnerSelectedListener(); private SpinnerSelectedListener cityListener = new SpinnerSelectedListener(); private SpinnerSelectedListener regionListener = new SpinnerSelectedListener(); //当前选择地区的索引值 private int provinceId = -1; private int cityId = -1; private int regionId = -1; /**选择按钮*/ private Button btnSelect = null; /**回调用事件*/ private OnSelectorCancel selectorCancel = null; @Override public void init(Context context) { // TODO Auto-generated method stub this.context = context; dialog = new Dialog(this.context,R.style.CustomDialog); dialog.setContentView(R.layout.adress_selector); spnProvince = (Spinner)dialog.findViewById(R.id.spin_province); spnProvince.setTag(new Integer(INDEX_PROVINCE)); spnCity = (Spinner)dialog.findViewById(R.id.spin_city); spnCity.setTag(new Integer(INDEX_CITY)); spnRegion = (Spinner)dialog.findViewById(R.id.spin_region); spnRegion.setTag(new Integer(INDEX_REGION)); btnSelect = (Button)dialog.findViewById(R.id.btn_select); btnSelect.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub selectAddress(); } }); //当对话框隐藏后调用[回调事件] dialog.setOnCancelListener(new OnCancelListener(){ @Override public void onCancel(DialogInterface arg0) { // TODO Auto-generated method stub if (selectorCancel != null) { String proName = ""; String cityName = ""; String regName = ""; try { Province tmpPro = china.provinceLst.get(provinceId); proName = tmpPro.areaName; City tmpCity = tmpPro.cityLst.get(cityId); cityName = tmpCity.areaName; Region tmpReg = tmpCity.regionLst.get(regionId); regName = tmpReg.areaName; } catch (Exception e) { android.util.Log.e("selectorCancel???", e.getMessage()); } selectorCancel.onSelectorResult(proName, cityName, regName); } } }); //加载数据 if (china == null) { loadCountryAddressData(); } //加载完后,初始化适配器 initAdapters(); } @Override public void update(Object obj) { // TODO Auto-generated method stub } private void loadCountryAddressData() { try { /** * 反序化的包名,类名,版本ID必须一致,否则ClassNotFoundException */ InputStream stream = this.context.getAssets().open("china-city.obj"); china = Country.loadFromStream(stream); //mHandler.sendEmptyMessage(0); } catch (Exception e) { android.util.Log.e("error", e.getMessage()); } } class SpinnerSelectedListener implements OnItemSelectedListener{ @Override public void onItemSelected (AdapterView parent, View view, int position, long id) { // TODO Auto-generated method stub //android.util.Log.i("", String.format("[pos=%d]",position)); int index = (Integer)parent.getTag(); //ArrayAdapter obj = (ArrayAdapter)(parent.getAdapter()); //String value = obj.getItem(position); //android.util.Log.i("", "value=" + value); if (index == INDEX_PROVINCE) { provinceId = position; if (isValideProvinceIndex(provinceId)) { //改变城市选择 Province tmpProvince = china.provinceLst.get(provinceId); String lstNames[] = tmpProvince.listNames(); if (lstNames == null) { //没有城市,当然没区县 provinceId = -1; spnCity.setVisibility(View.INVISIBLE); regionId = -1; spnRegion.setVisibility(View.INVISIBLE); return ; } else { if (spnCity.getVisibility() == View.INVISIBLE) { spnCity.setVisibility(View.VISIBLE); } if (spnRegion.getVisibility() == View.INVISIBLE) { spnRegion.setVisibility(View.INVISIBLE); } } dptCity = new ArrayAdapter(context, android.R.layout.simple_spinner_item, lstNames); dptCity.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spnCity.setAdapter(dptCity); spnCity.setOnItemSelectedListener(cityListener); } } else if (index == INDEX_CITY) { cityId = position; if (isValideCityIndex(provinceId,cityId)) { //改变区选择 Province tmpProvince = china.provinceLst.get(provinceId); City tmpCity = tmpProvince.cityLst.get(cityId); String lstNames[] = tmpCity.listNames(); if (lstNames == null) { //没有区县 regionId = -1; spnRegion.setVisibility(View.INVISIBLE); return ; } else if (spnRegion.getVisibility() == View.INVISIBLE) { spnRegion.setVisibility(View.VISIBLE); } dptRegion = new ArrayAdapter(context, android.R.layout.simple_spinner_item, lstNames); dptRegion.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spnRegion.setAdapter(dptRegion); spnRegion.setOnItemSelectedListener(regionListener); } } else if (index == INDEX_REGION) { regionId = position; } } @Override public void onNothingSelected(AdapterView parent) { // TODO Auto-generated method stub } } private void initAdapters() { dptProvince = new ArrayAdapter(this.context, android.R.layout.simple_spinner_item, china.listNames()); //设置下拉列表的风格 dptProvince.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置适配器 spnProvince.setAdapter(dptProvince); //设置侦听事件 spnProvince.setOnItemSelectedListener(proListener); } private boolean isValideProvinceIndex(int index) { return (china != null) && (index >= 0 && index = 0) && (china.provinceLst.get(provinceIndex).cityLst.size() > cityIndex); } return false; } private void selectAddress() { hide(); } /** * 调协回调事件 * @param selectorCancel */ public void setOnSelectorCancel(OnSelectorCancel selectorCancel) { this.selectorCancel = selectorCancel; } /** * 选择器关闭后,调用回调事件接口 */ public interface OnSelectorCancel { /** * @param proName 省份名 * @param cityName 城市名 * @param regName 区县名 */ public void onSelectorResult(String proName,String cityName,String regName); }; }

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值