【发布时间】:2014-01-03 19:00:19
【问题描述】:
如何在不提供相对布局中的左右参考的情况下将我的标志对齐在中心?这可能吗?
Logo id 是“windowtitle”,当前对齐是这样的:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#e7ebee"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="452dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#0a2436"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/back" />
<ImageView
android:id="@+id/inboxheader"
android:layout_width="2dip"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_toRightOf="@+id/back"
android:background="#85929B"
android:paddingBottom="15dip"
android:paddingTop="15dip" />
<ImageView
android:id="@+id/windowtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_toRightOf="@+id/inboxheader"
android:background="#0a2436"
android:gravity="center_horizontal|center_vertical"
android:paddingBottom="10dip"
android:paddingTop="10dip"
android:src="@drawable/logo" >
</ImageView>
</RelativeLayout>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:divider="@android:color/darker_gray"
android:dividerHeight="1dip"
android:drawSelectorOnTop="false"
android:focusable="false"
android:paddingTop="0dip" />
<!-- android:divider="@color/listDivider" -->
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:gravity="bottom" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#092435"
android:gravity="center_horizontal" >
<Button
android:id="@+id/btnManualLookup"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#4982AE"
android:gravity="center"
android:padding="15dip"
android:text="Activity"
android:textColor="#ffffff" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginBottom="6dip"
android:layout_marginTop="6dip"
android:background="#85929B" />
<Button
android:id="@+id/supportbutton"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#092435"
android:gravity="center"
android:padding="15dip"
android:text="Support"
android:textColor="#ffffff" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginBottom="6dip"
android:layout_marginTop="6dip"
android:background="#85929B" />
<Button
android:id="@+id/messagebutton"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#092435"
android:gravity="center"
android:padding="15dip"
android:text="Messages"
android:textColor="#ffffff" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
【问题讨论】: