【发布时间】:2012-04-30 19:16:43
【问题描述】:
我在 FrameLayout 中的 ImageView 上放置了一个 TextView。我已经为 TextView 尝试了各种 android:background 组合,但总是得到一个透明的灰色背景。我想要一个透明的背景。 android:background 属性似乎被忽略了。
<HorizontalScrollView
android:id="@+id/categories_horizontal_scrollview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="25dip">
<LinearLayout
android:id="@+id/categories_linear_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/photos_imageview"
android:scaleType="center"
android:src="@drawable/photos_ipad" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/photos_text"
android:layout_marginBottom="10dip"
android:layout_gravity="center_horizontal|bottom"
android:padding="3dip"
android:background="#00000000"
android:textColor="#ffffffff"
android:textSize="20dip"
/>
</FrameLayout>
.
.
【问题讨论】:
-
如果你想在文本视图后面使用图像,为什么不把图像设置为文本视图的背景呢?使用 android:backround="@drawable/photos_ipad"
-
另外,尝试使用 Android 的内置颜色作为文本视图上的透明背景 (android:background="@android:color/transparent")
-
您的 textview 不在 imageview 上...
-
我试过 android:background="android:color/transparent",它没有用。我做框架布局的原因是我需要文本位于图像的底部。
-
如果它不起作用,究竟发生了什么?它可能与您的滚动视图有关。我会先制作一个只有框架布局和 imageview/textview 的测试应用程序。看看透明度是否有效。然后添加线性布局。然后是滚动视图。看看你能不能找出问题出在哪里。
标签: android background textview imageview android-framelayout