SJ64 1B&PS1

1B:
将不同的views组合在一起,称之为viewgroups。
讲了两个布局:
LinearLayout
RelativeLayout
以及
内边距padding和外边距margin的效果及区别。
此次学习 主要是更加深了对这些基础的认识。

最后关于采访那段感觉还有挺有收获的:
模块化开发?(可以经常地复用 提高开发效率。
布局只是开始 布局之后还有各种处理 网络访问 数据储存等。
还有布局设计不需要大材小用 比如一些布局可以用简单的LinearLayout实现 就不建议用功能强大而复杂的RelativeLayout实现。
(1B)

PS1:

最后是一个生日贺卡app,再简单也要自己动手实践:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout    
    xmlns:android="http://schemas.android.com/apk/res/android"      
    xmlns:tools="http://schemas.android.com/tools"    
    android:layout_width="match_parent"    
    android:layout_height="match_parent">    
    <ImageView        
        android:layout_width="match_parent"        
        android:layout_height="match_parent"        
        android:src="@drawable/happybirthday"        
        android:scaleType="centerCrop"/>    
    <TextView        
        android:layout_width="wrap_content"        
        android:layout_height="wrap_content"       
        android:textSize="38sp"        
        android:fontFamily="sans-serif-light"        
        android:text="Hello Birthday, Ga!"                   
        android:textColor="@android:color/white"          
        android:padding="16dp"/>    
    <TextView        
        android:layout_width="wrap_content"        
        android:layout_height="wrap_content"        
        android:text="From flyntsyc."        
        android:textSize="24sp"        
        android:textColor="@android:color/white"        
        android:layout_alignParentBottom="true"        
        android:layout_alignParentRight="true"        
        android:layout_margin="16dp"/>
</RelativeLayout>

效果图:

Screenshot_2016-04-19-00-00-02.png

看见标题栏不太美观:
于是在BirthdayActivity的setContentView方法前添加了:

requestWindowFeature(Window.FEATURE_NO_TITLE);

但出现:

Paste_Image.png

查找 发现有三种解决办法:
1.如果继承的是ActionBarActivity或者是AppCompatActivity就会报错。如果你执意要用这个方法,则改为继承Activity。
2.改用supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
3.在清单文件里改theme

最后采用了第二种方法:效果如图:

Screenshot_2016-04-19-14-50-49.png

(PS1 Done)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容