2017Google Study Jams之1A对View和Vi

2017-03-12  本文已影响43人  Shawpoo的

此次活动的举办方:Google Study Jams活动官网

我的博客(同步此次活动笔记):CSDN博客我的简书

Google Developers

一、1A 认识View的笔记

1、初识Android

2、认识Android的View(视图)

3、认识XML

4、开启View的第一个控件:TextView(文本视图)

<TextView
        android:id="@+id/title_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/my_photos"
        android:textAppearance="?android:textAppearanceLarge"
        android:textColor="#4689C8"
        android:textStyle="bold" />

5、ImageView (图像视图)

<ImageView
      android:id="@+id/photo_image_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:src="@drawable/icon"
      android:scaleType="centerCrop"/>

6、通过看Android开发文档帮助开发

二、1B 认识ViewGroup的笔记

1、认识ViewGroup

2、初识布局(Layout)-线性布局(LinearLayout)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
     <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮1"/>   
     <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮2"/>   
     <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮3"/>   
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
     <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮1"/>   
     <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮2"/>   
     <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮3"/>   
</LinearLayout>
水平布局 垂直布局

3、相对布局(RelativeLayout)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
    <ImageView
        android:id="@+id/image_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@mipmap/ic_launcher"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@id/image_center"
        android:text="我在左边"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_above="@id/image_center"
        android:text="我在上边"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/image_center"
        android:text="我在右边"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@id/image_center"
        android:text="我在下边"/>
</RelativeLayout>
相对布局效果图

4、优化布局-设定布局的内外边距(Paddding、Margin)

内外边距说明

OK,关于View和ViewGroup的认识就记到这里了。感觉各位的阅读!

上一篇 下一篇

猜你喜欢

热点阅读