アイコンを希望の位置に配置するのに苦労しました.3つの異なるスタックオーバーフローの質問を見て、画像をRelativeLayout、LinearLayout、およびTableRowに配置しようとしました。すべてにさまざまな XML オプションがあります。アイコンを正しく配置し、割り当てられたスペースの上下の中央に配置することができませんでした。下の写真では、赤が現在の位置、青が希望の位置です。これが写真(現在の外観ですが、これは正しくありません)とコードです(imageView1は私が整列させたいものです):
そしてコード:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:id="@+id/loginScrollView">
<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:padding="5dp">
<ImageView android:id="@+id/logoImageView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/logo" android:contentDescription="@string/app_name" />
<TextView android:id="@+id/demoTextView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/logDetails" android:gravity="center_horizontal|center" />
<EditText android:id="@+id/emailEditText"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:hint="@string/loginHint" android:imeOptions="actionNext"
android:inputType="textEmailAddress" android:padding="20dp" />
<EditText android:id="@+id/passEditText"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:hint="@string/password" android:imeOptions="actionDone"
android:inputType="textPassword" android:padding="20dp" />
<TableRow android:id="@+id/rememberTableRow"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="@+id/rememberTextView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/rememberDetails" android:layout_gravity="center" />
<CheckBox android:id="@+id/rememberCheckBox"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:padding="20dp" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="showPopup"
android:src="@drawable/abs__ic_menu_moreoverflow_holo_dark" android:layout_weight="1" android:layout_gravity="center|right"/>
</TableRow>
<TableRow android:id="@+id/buttonTableRow"
android:layout_width="match_parent" android:layout_height="wrap_content">
<Button android:id="@+id/registerButton" android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_gravity="bottom"
android:layout_weight="1" android:text="@string/register" />
<Button android:id="@+id/loginButton" android:layout_width="0dip"
android:layout_height="wrap_content" android:layout_gravity="bottom"
android:layout_weight="1" android:text="@string/login" />
</TableRow>
</TableLayout>
</ScrollView>