使用透明度叠加的图像应用背景图像时未对齐

时间:2013-06-04 17:59:33

标签: android layout background alignment overlay

我正在尝试创建一个底部有透明度叠加层的图像,对齐图像的右侧和左侧。到目前为止,我已经能够使用以下布局

执行此操作
          <FrameLayout
            android:layout_width="310px"
            android:layout_height="300px"
            android:paddingLeft="0dp" >

            <ImageView
                android:id="@+id/image"
                android:layout_width="300px"
                android:layout_height="300px"
                android:layout_gravity="left"
                android:src="@drawable/color_test_pattern" />

            <View
                android:id="@+id/overlay"
                android:layout_width="300px"
                android:layout_height="50dp"
                android:layout_gravity="bottom"
                android:background="#99000000" />

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:text="This is A Title"
                android:textColor="#ffffff" />
        </FrameLayout>

很好地给了我:

enter image description here

这样可以正常工作并生成我的叠加层,但是当我尝试为图像设置背景阴影时,我遇到了问题,叠加层没有正确对齐,而是覆盖了图像的底部和右侧。

与上述布局的唯一区别是imageView现在将背景设置为阴影

<ImageView  
android:id="@+id/image"
android:layout_width="300px" 
android:layout_height="300px" 
android:src="@drawable/color_test_pattern"
android:layout_gravity="left"
android:background="@drawable/shadow"
/>

这是结果

enter image description here

任何想法如何补救?

0 个答案:

没有答案