今天上午面试了某家互联网公司,口号是你去不了阿里巴巴,但是你可以来阿拉丁。。。。公司在大望路这里,一去先做了一套笔试题,感觉有点难。算法题挺多。我粗略回忆一下。幸好我拍下来了。
1. 写一标准的宏MIN,这个宏输入两个参数并返回一个较小的值。
2.描述c程序的内存分配以及他们的区别
3.在不借助三个变量 的情况下,把两个int的变量x,y互换,
4.mysql中的join方式有几种,区别是什么?
5.一个tb1,字段是name,class ,score分别代表姓名,所在班级,分数,要求用一条查询语句查出每个班的及格人数和不及格人数,格式为:class,及格人数,不及格人数。
6.TCP与UDP分别位于网络协议七层的哪一层?并简述二者区别?
7.什么是死锁?举一个多线程产生死锁的例子?
8.进程与线程之间的区别,与联系?
9.列举常用的排序算法,说出排序思想和时间复杂度
程序题,给定两个数A,B不使用除法和取模算法,求A/B的商和余数?
找出单链表的中间节点
2个有序整数组,A[N],B[N]求他们的交集
设计一个栈,要求能提供max操作函数,且算法复杂度为o(n)
最后说下面试的问题?
怎么解决内存优化,内存溢出?
Activity的四种启动模式?
Fragment的优点,
Rxjava的优点。面试官人的确很nice有大公司的风范。我们在布局上就weight 争论了一番。
weight的用处。
首先声明只有在Linearlayout中,该属性才有效。之所以Android:layout_weight会引起争议,是因为在设置该属性的同时,设置android:layout_width为wrap_content和match_parent会造成两种截然相反的效果。如下所示:
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:background="@android:color/black"
- android:text="111"
- android:textSize="20sp" />
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="2"
- android:background="@android:color/holo_green_light"
- android:text="222"
- android:textSize="20sp" />
上面的布局将两个TextView的宽度均设为match_parent,一个权重为1,一个权重为2.得到效果如下:
可以看到权重为1的反而占了三分之二!
再看如下布局:
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:background="@android:color/black"
- android:text="111"
- android:textSize="20sp" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="2"
- android:background="@android:color/holo_green_light"
- android:text="222"
- android:textSize="20sp" />
- </LinearLayout>
即宽度为wrap_content,得到视图如下:
左边 TextView占比三分之一,又正常了。
android:layout_weight的真实含义是:一旦View设置了该属性(假设有效的情况下),那么该 View的宽度等于原有宽度(android:layout_width)加上剩余空间的占比!
设屏幕宽度为L,在两个view的宽度都为match_parent的情况下,原有宽度为L,两个的View的宽度都为L,那么剩余宽度为L-(L+L) = -L, 左边的View占比三分之一,所以总宽度是L+(-L)*1/3 = (2/3)L.事实上默认的View的weight这个值为0,一旦设置了这个值,那么所在view在绘制的时候执行onMeasure两次的原因就在这。
Google官方推荐,当使用weight属性时,将width设为0dip即可,效果跟设成wrap_content是一样的。这样weight就可以理解为占比了!
转载地址:http://blog.csdn.net/yanzi1225627/article/details/24667299