【发布时间】:2014-06-12 21:49:25
【问题描述】:
我的片段 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"
android:background="@drawable/wg_blurred_backgrounds_14"
>
<ImageView
android:id="@+id/sphereIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="@string/magicBallDescr"
android:src="@drawable/rsz_31mystic" />
<LinearLayout
android:id="@+id/table"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/sphereIcon"
android:orientation="vertical" >
<TextView
android:id="@+id/txtAnswer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<EditText
android:id="@+id/txtQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:hint="@string/textHint"
android:inputType="textMultiLine"
android:lines="6" />
<Button
android:id="@+id/btnAsk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/btnAskQ"
android:paddingEnd="@dimen/activity_vertical_margin"
/>
</LinearLayout>
</RelativeLayout>
这是它的外观:
现在我想在EditText 上设置一个不同的背景图片,所以我编辑了 xml 并使其如下:
<EditText
android:id="@+id/txtQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:hint="@string/textHint"
android:inputType="textMultiLine"
android:lines="6"
android:background="@drawable/background"/>
但现在我在EditText 上设置的背景占据了整个LinearLayout 空间。
以下是更改后在编辑器中的外观:
为什么它占据了整个位置并隐藏了按钮?
我在这里缺少什么?我敢肯定它很小,但我无法发现它。
【问题讨论】:
-
背景图片的尺寸是多少?好像有 id
Out of Memory错误。 -
在更改后尝试清理您的项目,同时确保您的 editText id 与您的活动代码中的相同,并且您在 setContentView 中使用了正确的 xml
-
@vjdhama 哦。它是 273 508 字节。好的 解决了一个问题,但是为什么它需要整个
LinearLayout而不是EditText?
标签: java android xml android-fragments android-activity