我有这个标记:
<LinearLayout
android:id="@+id/authorDetails"
style="@style/authorDetails">
<ImageView
android:id="@+id/authorPic"
style="@style/authorPic" />
<TextView
android:id="@+id/authorName"
style="@style/authorName"
android:text="author name" />
</LinearLayout>
这种风格:
<style name="authorDetails">
<item name="android:layout_below">@id/header</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">89dip</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">@drawable/bg</item>
</style>
<style name="authorPic">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:src">@drawable/xxx</item>
</style>
<style name="authorName">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
你知道吗?
LinearLayout 的背景覆盖了内容(ImageView 和TextView)。这是为什么?我不明白!如果我取出关于 LinearLayout bg 的声明,内容会重新出现。
请帮忙!
最佳答案
我也遇到过这个问题,虽然很久以前就有人问过这个问题,但我发布了这个回复,因为它可能会对阅读此主题的人有所帮助。从我在案例中看到的情况来看,问题是由我用作背景的 9patch 图像引起的。在“nourdine”的情况下,“@drawable/bg”文件可能是一个 9patch 文件。使用普通图像应该可以解决问题。
关于android - 覆盖其内容的 LinearLayout 的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3142231/