1. 程式人生 > >DiyCode開源項目 AboutActivity分析

DiyCode開源項目 AboutActivity分析

play horizon click 分析 toolbar war none dsc pos

1.首先看一下效果

這是手機上顯示的效果:

技術分享

1.1首先是一個標題欄,左側一個左箭頭,然後一個圖標。

1.2然後下方是一個可以滑動的頁面。

1.3分成了7個部分。

1.4DiyCode的圖標。

1.5然後是Diycode一個什麽樣的社區?

1.6我是誰?

1.7我爸爸?

1.8GcsSloop==>一個生活在2.5次元的魔法師。

1.9捐贈一杯咖啡。

1.10License

1.11--diycode--


2.分析一下布局文件

布局文件:activity_about.

技術分享
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright 2017 GcsSloop
  
~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. ~ ~ Last modified 2017-03-25 02:42:10 ~ ~ GitHub: https://
github.com/GcsSloop ~ Website: http://www.gcssloop.com ~ Weibo: http://weibo.com/GcsSloop --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_about" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.gcssloop.diycode.activity.AboutActivity"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content"/> <android.support.v4.widget.NestedScrollView android:layout_below="@id/toolbar" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginTop="30dp" android:src="@drawable/ic_logo"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:gravity="center" android:text="@string/about_diycode_title" android:textSize="16sp" android:textStyle="bold"/> <TextView android:id="@+id/textView2" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="12dp" android:text="@string/about_diycode_desc" android:textSize="14sp"/> <View android:layout_width="match_parent" android:layout_height="8dp" android:layout_marginBottom="10dp" android:background="@color/diy_white_bg"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:gravity="center" android:text="@string/about_me_title" android:textSize="16sp" android:textStyle="bold"/> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/my_desc" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="12dp" android:paddingRight="12dp" android:paddingTop="12dp" android:text="@string/about_me_desc" android:textSize="14sp"/> <TextView android:id="@+id/feed_back" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/my_desc" android:gravity="center" android:paddingBottom="12dp" android:paddingTop="12dp" android:text="點擊此處告狀" android:textSize="10sp"/> </RelativeLayout> <View android:layout_width="match_parent" android:layout_height="8dp" android:layout_marginBottom="10dp" android:background="@color/diy_white_bg"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:gravity="center" android:text="@string/about_father" android:textSize="16sp" android:textStyle="bold"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="12dp" android:paddingRight="12dp" android:paddingTop="12dp" android:text="@string/about_father_desc" android:textSize="14sp"/> <View android:layout_width="match_parent" android:layout_height="8dp" android:layout_marginTop="12dp" android:background="@color/diy_white_bg"/> <RelativeLayout android:id="@+id/github" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="12dp"> <ImageView android:id="@+id/image" android:layout_width="40dp" android:layout_height="40dp" android:layout_marginRight="12dp" android:src="@drawable/about_sloop"/> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:layout_toRightOf="@+id/image" android:gravity="center" android:text="GcsSloop" android:textSize="16sp" android:textStyle="bold"/> <TextView android:id="@+id/desc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/name" android:layout_marginTop="2dp" android:layout_toRightOf="@+id/image" android:gravity="center" android:text="一位生活在 2.5 次元的魔法師。" android:textSize="12sp" /> </RelativeLayout> <View android:layout_width="match_parent" android:layout_height="8dp" android:background="@color/diy_white_bg"/> <TextView android:id="@+id/contribute" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:gravity="center" android:padding="12dp" android:text="¥ 捐贈一杯咖啡" android:textColor="#4AC432" android:textSize="16sp"/> <View android:layout_width="match_parent" android:layout_height="8dp" android:background="@color/diy_white_bg"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:gravity="center" android:text="License" android:textSize="16sp" android:textStyle="bold"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="12dp" android:text="@string/about_license_desc" android:textSize="14sp"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/diy_white_bg" android:gravity="center_horizontal" android:paddingBottom="16dp" android:paddingTop="12dp" android:text="-- diycode --"/> </LinearLayout> </android.support.v4.widget.NestedScrollView> </RelativeLayout>
View Code

外層:RelativeLayout

然後是一個Toolbar和一個NestedScrollView並列。

2.1.android.support.v7.widget.Toolbar

  參考一下這篇文章==>講解了Toolbar

   技術分享

2.2.android.support.v4.widget.NestedScrollView

  不懂NestedScrollView,可以參考一下這篇文章。  


3.一些示例文字

第三段


4.一些示例文字

第四段


5.一些示例文字

第五段


6.一些示例文字

第六段



DiyCode開源項目 AboutActivity分析