为什么布局因为背景而延伸

时间:2014-09-18 12:56:17

标签: android android-layout background

我有布局大小1,当我设置背景我得到大小2,我怎么能使图层不被拉伸?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/items_pad_left"
android:paddingRight="@dimen/items_pad_right"
android:background="@drawable/item_background">

enter image description here

2 个答案:

答案 0 :(得分:0)

因为您正在使用:android:layout_height="match_parent"

使用wrap_content代替100dp

等任意大小

答案 1 :(得分:0)

您可以通过设置固定的宽度和高度来实现。喜欢 -

  

机器人:layout_width = “200dp”   机器人:layout_height = “100dp”