小結:
android:paddingLeft:指的是在本控制項中,預留閑置多少空間
android:layout_marginLeft:指的是這個控制項距離父控制項的空間有多少
<LinearLayout<br /> android:layout_height = "28px"<br /> android:layout_width="fill_parent"<br /> android:orientation="horizontal"<br /> android:gravity="center_vertical"<br /> android:paddingLeft="25px"<br /> android:background ="@drawable/top_bg"<br /> ><br /> <ImageView<br /> android:layout_width="18px"<br /> android:layout_height="18px"<br /> android:src="@drawable/manage"<br /> ></ImageView><br /> <TextView<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content"<br /> android:textColor="#000"<br /> android:textSize="14px"<br /> android:text="應用程式"<br /> ></TextView><br /> </LinearLayout></p><p>
android:paddingLeft:指的是在本控制項中,預留閑置多少空間
<LinearLayout<br /> android:layout_height = "28px"<br /> android:layout_width="fill_parent"<br /> android:orientation="horizontal"<br /> android:gravity="center_vertical"<br /> android:layout_marginLeft="25px"<br /> android:background ="@drawable/top_bg"<br /> ><br /> <ImageView<br /> android:layout_width="18px"<br /> android:layout_height="18px"<br /> android:src="@drawable/manage"<br /> ></ImageView><br /> <TextView<br /> android:layout_width="wrap_content"<br /> android:layout_height="wrap_content"<br /> android:textColor="#000"<br /> android:textSize="14px"<br /> android:text="應用程式"<br /> ></TextView><br /> </LinearLayout>
android:layout_marginLeft:
指的是這個控制項距離父控制項的空間有多少
gravity 這個英文單詞是重心的意思,在這裡就表示固定位置的意思。
android:layout_gravity 和 android:gravity 的區別
從名字上可以看到,android:gravity是對元素本身說的,元素本身的文本顯示在什麼地方靠著換個屬性設定,不過不設定預設是在左側的。
android:layout_gravity是相對與它的父元素說的,說明元素顯示在父元素的什麼位置。
比如說button: android:layout_gravity 表示按鈕在介面上的位置。 android:gravity表示button上的字在button上的位置。