android:gravity sets the gravity of the content of the View its used on.
android:layout_gravity sets the gravity of the View or Layout in its parent.
ex:
<Button
android:id="@+id/addFoodDateButton"
android:layout_width="140dp"
android:layout_height="40dp"
android:layout_marginTop="12dp"
android:layout_marginLeft="12dp"
android:textColor="#000000"
android:background="@android:color/transparent"
android:layout_toRightOf="@id/addFoodDateTitleImageView"
android:text="2013-09-12"
android:gravity="left|center_vertical"
/>
android:gravity
center_vertical, top , bottom
ex:
calorieTextView.setGravity(Gravity.CENTER);
沒有留言:
張貼留言