Androidのメーカー研究ノート(2)

今日、我々はRelativeLayoutのAndroidメーカーの相対的な配置を学んでいます

1.相対レイアウト(フォーカス)するように相対配置コントロールの相対的な位置決めの仕方によっては、任意の位置のレイアウトで表示されます。 

コントロール配置位置の相対配置が指定されていない場合、デフォルトのコントロールは、左上隅のRelativeLayoutに配置されます。だから、最初の最初のコントロールの場所を指定し、[コントロールに応じて他のコントロールレイアウトに行きます。

2. RelativeLayoutの共通の属性:

コントロールのレイアウトに親要素に対しては、
    アンドロイド:layout_centerHrizontalを中心はトゥーレレベルである場合 
    アンドロイド:それはトゥーレある場合layout_centerVerticalは、垂直中心 
    アンドロイド:親要素にlayout_centerInparentに対しては完全に中心 
    アンドロイド:layout_alignParentBottomの下縁の親要素内に配置 
    左端が位置する親要素をlayout_alignParentLeft:アンドロイド 
    アンドロイド:親要素の右端に位置するlayout_alignParentRightは 
    アンドロイド:親要素の端に位置layout_alignParentTopは 
    アンドロイド:対応する兄弟は、親要素への参照を作成する単語を見つけることができない場合layout_alignWithParentIfMissing 

属性値は、「ID / ID名@」名前を参照する必要のIDである 
    アンドロイド:下方に位置layout_below要素 
    アンドロイド:layout_aboveの要素上 
    アンドロイド:の左側にlayout_toLeftOf要素 
    右layout_toRightOf配置要素:アンドロイド 

    アンドロイド:上縁要素と要素の上縁を整列さlayout_alignTop 
    アンドロイド:layout_alignLeft要素の要素の左端の左のエッジが整列される 
    アンドロイド:要素と要素の下縁layout_alignBottom下縁が整列され 
    アンドロイド。要素の右端の右及び素子エッジ整列をlayout_alignRight 

プロパティに画素値を付与
    アンドロイド:下端layout_marginBottomから 
    左layout_marginLeftからの距離:アンドロイド 
    の右端からlayout_marginRight:アンドロイド 
    アンドロイド:layout_marginTop上のエッジからの距離

今日学んだこの知識を使用して、少しのデモを行います。

 

まず、Skypeの絵を見つけるために、ライブラリBaiduの、そしてアリは、これらのアイコンを見つけるためのアイコンを使用することである。そして、カラーピッカーをダウンロードしてください。

コードの場合:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    //设置了为线性布局
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"      //对局为垂直对齐
android:background="#00aff0"       //设置背景色,用取色器
tools:context=".MainActivity">

<RelativeLayout              //采用相对布局
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp">

<Button
android:textColor="@android:color/white"
android:id="@+id/bt_ms_account"
android:background="@drawable/bg_blue"
android:layout_alignParentBottom="true"
android:text="MS账号"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<Button
android:id="@+id/bt_sk_account"
android:textColor="@android:color/white"
android:layout_marginBottom="20dp"
android:layout_above="@id/bt_ms_account"
android:background="@drawable/bg_blue"
android:text="skype用户"
android:layout_width="match_parent"
android:layout_height="wrap_content" />



<ImageView
android:id="@+id/im_count"
android:layout_centerHorizontal="true"
android:layout_marginBottom="0dp"
android:layout_above="@id/bt_ms_account"
android:src="@drawable/icon"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</RelativeLayout>



<RelativeLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:layout_marginTop="20dp"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">


<ImageView
android:layout_weight="1"
android:src="@drawable/windows"
android:layout_width="0dp"
android:layout_height="22dp" />
<ImageView
android:layout_weight="1"
android:src="@drawable/mail"
android:layout_width="0dp"
android:layout_height="22dp" />
<ImageView
android:layout_weight="1"
android:src="@drawable/skype"
android:layout_width="0dp"
android:layout_height="22dp" />
<ImageView
android:layout_weight="1"
android:src="@drawable/xbox"
android:layout_width="0dp"
android:layout_height="22dp" />
<ImageView
android:layout_weight="1"
android:src="@drawable/cloud"
android:layout_width="0dp"
android:layout_height="22dp" />

</LinearLayout>
<TextView
android:id="@+id/tv_count"
android:textColor="@android:color/white"
android:background="#00a3de"
android:padding="15dp"
android:layout_alignParentBottom="true"
android:textSize="20dp"
android:text="创建账号"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/tv_login"
android:textColor="@android:color/white"
android:gravity="center"
android:layout_marginBottom="25dp"
android:layout_above="@id/tv_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录"/>
</RelativeLayout>

</LinearLayout>

 

 

已上就是今天的学习内容,加油!

おすすめ

転載: www.cnblogs.com/xiaojian98/p/11939398.html