Java 如何以xml样式水平拉伸背景?
我正在尝试将Java 如何以xml样式水平拉伸背景?,java,android,xml,android-layout,styles,Java,Android,Xml,Android Layout,Styles,我正在尝试将calendar\u header.png中的垂直线水平拉伸,作为xml样式的背景: <style name="CaldroidCalendarViewLayout"> <item name="android:background">@drawable/calendar_header</item> </style> @可拉伸/日历头 但它会根据背景的高度改变控件的高度。我怎样才能解决这个问题?我只想用拉伸的背景填充控件的实
calendar\u header.png
中的垂直线水平拉伸,作为xml样式的背景:
<style name="CaldroidCalendarViewLayout">
<item name="android:background">@drawable/calendar_header</item>
</style>
@可拉伸/日历头
但它会根据背景的高度改变控件的高度。我怎样才能解决这个问题?我只想用拉伸的背景填充控件的实际大小。(就像背景图像是内容的一部分,而不仅仅是背景。)下面的答案帮助了我:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:src="@drawable/activation_popup"
android:scaleType="fitXY"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignTop="@+id/activation_layout"
android:layout_alignBottom="@id/activation_layout"
android:layout_alignLeft="@id/activation_layout"
android:layout_alignRight="@id/activation_layout"
android:contentDescription="@string/act_code_label" />
<LinearLayout
android:id="@id/activation_layout"
android:clipToPadding="true"
android:padding="25dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- LinearLayout wraps a bunch of smallish views here -->
</LinearLayout>
</RelativeLayout>