我有一个LinearLayout
它有一个背景图像(9修补png文件)。 如何将填充添加到左侧和右侧,以便背景图像不占据整个宽度?我试过android:paddingLeft
和android:paddingRight
,但这并没有改变任何东西。如何为背景图像添加填充
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="25dip"
android:paddingRight="25dip"
android:background="@drawable/background">
整个背景仍然延伸整个屏幕宽度。
这不是那么好,因为它增加了层次深度。你能否详细说明如何用XML实现这个答案? – 2013-04-25 17:36:53
我已经发布了另一个使用插入drawable的解决方案,所以不需要扩展。谢谢。 – 2013-04-26 09:30:52
您可以通过使用FrameLayout更改外部LinearLayout来改善此布局 – vovahost 2014-11-10 16:50:03