所以我要做的是显示列表行元素的背景。我创建了行布局和应用样式:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout1" android:layout_width="fill_parent"
android:layout_height="fill_parent"
style="@style/product1" >
我将样式设置为:
<style name="product1">
<item name="android:background">@drawable/product1</item>
</style>
和product1.xml as:
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/prod1"
android:antialias="true"
android:dither="true"
android:filter="false"
android:gravity="right"
android:scaleType="fitXY" />
其中prod1.9.png是一个九个补丁集,可以向上和向左缩放(所以我希望我的图像在右下角)
但我现在面临的问题是,角落里会显示图标,而9patch不会左右缩放。
如果不是使用样式我放android:background=@drawable/prod1
然后它会缩放,但每一行都变得非常大。有什么想法吗?
答案 0 :(得分:0)
我没有用你的代码验证这一点,但首先想到的是(假设使用'android:background'而不是样式),而不是在行布局上:
android:layout_height="fill_parent"
设定固定高度:
android:layout_height="30dp"
它不够灵活,但它可能适合您的需求。