android - 覆盖其内容的 LinearLayout 的背景

标签 android

我有这个标记:

<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/

相关文章:

android - 接口(interface)未在 fragment 中调用

java - 使用 Retrofit Android 发送 ArrayList<String> 作为一部分

android - 这是 Android 设备上 "flickering issue on scrolling"的解决方案

java - Java android studio 项目中的NoFileFoundException

android - 具有隐式 Intent 的父 Activity

java - 如何将该项目导入到 Eclipse 中?

android - Activity 恢复后对新副本的 Viewpager fragment 引用

android - TaskStackBuilder 和后栈的附加功能

android - 为什么更改 GestureOverlayView 的 StrokeType 会影​​响 View 的标准行为?

android - Android 中的大 IndexBuffer