简单的Android界面创建

2017-03-01  本文已影响0人  热爱生活的男孩子

线性布局

线性布局:LinearLayout
控件特性:
LinearLayout是一种ViewGroup,在其内部的所有控件会呈线性排列,可以是水平的,也可以是垂直的。
继承结构:
View
-- ViewGroup
-- -- LinearLayout
核心属性:

相对布局

相对布局:RelativeLayout
控件特性:
在RelativeLayout下的每个子级控件都会以父级控件或同级别的其它控件作为参考,从而决定自身的尺寸和位置。
在RelativeLayout下的每个子级控件默认显示在左上角,根据代码顺序,后续出现的控件会覆盖此前出现的控件。
继承结构:
View
-- ViewGroup
-- -- RelativeLayout
核心属性:
(无)
子级控件属性:

文本显示控件

文本显示控件:TextView
控件特性:
用于显示文本(字符串),所有能够显示文本的控件都是TextView的子孙类。
继承结构:
View
-- TextView
核心属性:

文本输入控件

文本输入控件:EditText
控件特性:
使得用户在界面上输入内容!
继承结构:
View
-- TextView
-- -- EditText<

按钮控件

按钮控件:Button
控件特性:
用于被点击!
继承结构:
View
-- TextView
-- -- Button<

![Upload QQ截图20170301205058.png failed. Please try again.]

<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"
    android:background="@drawable/player_bg_beyond"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
    tools:ignore="HardcodedText,ContentDescription" >

    <RelativeLayout
        android:id="@+id/rl_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageButton
            android:id="@+id/ib_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:src="@drawable/player_ic_back" />

        <ImageButton
            android:id="@+id/ib_help"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:background="@null"
            android:src="@drawable/player_ic_help" />

        <TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@+id/ib_help"
            android:layout_toRightOf="@+id/ib_back"
            android:gravity="center"
            android:singleLine="true"
            android:text="海阔天空"
            android:textColor="#ffffff"
            android:textSize="18sp"
            android:textStyle="italic|bold" />

        <TextView
            android:id="@+id/tv_author"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tv_title"
            android:layout_toLeftOf="@+id/ib_help"
            android:layout_toRightOf="@+id/ib_back"
            android:gravity="center"
            android:singleLine="true"
            android:text="Beyond"
            android:textColor="#ffffff"
            android:textSize="14sp" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rl_lrc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/rl_current" >

        <TextView
            android:id="@+id/tv_lrc2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tv_lrc1"
            android:gravity="right"
            android:paddingBottom="5dp"
            android:paddingTop="5dp"
            android:text="那会怕有一天只你共我"
            android:textColor="#cccccc"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/tv_lrc1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="5dp"
            android:paddingTop="5dp"
            android:text="背弃了理想,谁人都可以"
            android:textColor="#ffffff" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rl_current"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="10dp"
        android:paddingBottom="8dp"
        android:layout_above="@+id/rl_play" >

        <ImageView
            android:id="@+id/iv_progress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="3dp"
            android:src="@drawable/player_ic_progress" />

        <TextView
            android:id="@+id/tv_current"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/iv_progress"
            android:textColor="#ffffff"
            android:text="3:52" />

        <TextView
            android:id="@+id/tv_duration"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/iv_progress"
            android:layout_alignParentRight="true"
            android:textColor="#ffffff"
            android:text="5:37" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rl_play"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <ImageButton
            android:id="@+id/ib_shuffle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:layout_centerVertical="true"
            android:src="@drawable/player_ic_shuffle" />

        <ImageButton
            android:id="@+id/ib_prev"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:layout_toLeftOf="@+id/ib_play"
            android:layout_centerVertical="true"
            android:src="@drawable/player_ic_prev" />

        <ImageButton
            android:id="@+id/ib_play"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_centerInParent="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:src="@drawable/player_ic_play" />

        <ImageButton
            android:id="@+id/ib_next"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/ib_play"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:src="@drawable/player_ic_next" />

        <ImageButton
            android:id="@+id/ib_fav"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"
            android:src="@drawable/player_ic_fav" />
    </RelativeLayout>

</RelativeLayout>

![Upload Paste_Image.png failed. Please try again.]。

上一篇 下一篇

猜你喜欢

热点阅读