為啥我的結(jié)果和老師的不太一樣呢?
和老師的代碼一樣咋效果不一樣呢?
activity_main.xml
<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" ????tools:context=".MainActivity"?> ??<include?layout="@layout/common_title"/> ????<TextView ????????android:layout_width="match_parent" ????????android:layout_height="wrap_content" ????????android:text="正文內(nèi)容" ????????android:textSize="18dp" ?????????/> </RelativeLayout>
common_title.xml
<?xml?version="1.0"?encoding="utf-8"?> <RelativeLayout?xmlns:android="http://schemas.android.com/apk/res/android" ????android:layout_width="match_parent" ????android:layout_height="wrap_content"? ????android:background="#000" ????android:paddingTop="10dp" ????android:paddingBottom="10dp" ????> ????<TextView ????????android:id="@+id/textView_Left_Common_Title" ????????android:layout_width="wrap_content" ????????android:layout_height="wrap_content" ????????android:layout_alignParentLeft="true" ????????android:layout_marginLeft="10dp" ????????android:layout_centerVertical="true" ????????android:textColor="#fff" ????????android:textSize="14sp" ????????android:text="返回"?/> ????<TextView ????????android:id="@+id/TextView_Context_Common_Title" ????????android:layout_width="wrap_content" ????????android:layout_height="wrap_content" ????????android:layout_centerInParent="true" ????????android:text="布局優(yōu)化" ????????android:textColor="#fff" ????????android:textSize="18sp"?/> ????<TextView ????????android:id="@+id/TextView_Right_Common_Title" ????????android:layout_width="wrap_content" ????????android:layout_height="wrap_content" ????????android:layout_alignParentRight="true" ????????android:layout_centerVertical="true" ????????android:layout_marginRight="10dp" ????????android:text="功能" ????????android:textColor="#fff" ????????android:textSize="14sp"?/> </RelativeLayout>
2015-05-29
相對(duì)布局中的
<include?layout="@layout/common_title"/> 與?
<TextView
????????android:layout_width="match_parent"
????????android:layout_height="wrap_content"
????????android:text="正文內(nèi)容"
????????android:textSize="18dp"
?????????/>這兩部分,沒有寫出相對(duì)位置的關(guān)系。