【发布时间】:2014-06-12 08:25:14
【问题描述】:
我有这个 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.gelasoft.answeringball.MainActivity$PlaceholderFragment" >
<ImageView
android:id="@+id/sphereIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:src="@drawable/rsz_rsz_mystic"
android:contentDescription="@string/magicBallDescr"/>
<LinearLayout
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/launch_codes"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/textHint"
android:inputType="text"
/>
</LinearLayout>
</RelativeLayout>
如您所见,我在 RelativeLayout 中包含了一个 LinearLayout,但我看到的与我想要做的相去甚远。
现在我的视图如下:
我 3 个问题:
为什么
LinearLayout会显示在球体图标上方?它被声明为RelativeLayout 的子代
如何将球体放置在线性布局视图上方?
-
如何使球体图标居中?我试过了
android:layout_centerVertical="true" android:layout_alignParentLeft="true"
但它会将图标放在视图的中心。我希望它在顶部居中。
我知道我在这里遗漏了一小部分,但作为一个 xml 初学者,我无法发现我的错误。
【问题讨论】:
标签: java android xml android-fragments android-activity