FrameLayout中的透明TextView背景

时间:2012-04-30 19:16:43

标签: android background textview imageview android-framelayout

我在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>
              .
              .

3 个答案:

答案 0 :(得分:0)

使用此:

TextView tv;
tv.setBackgroundColor(0xXX??????);

XX - [00; FF] - 转换指标。 ?????? - 一些数字(原始颜色)

希望它有所帮助)))

答案 1 :(得分:0)

正如Brayden指出的那样,布局存在问题。我最终将ImageView和TextView作为单一资源放入FrameLayout,然后在需要的地方动态添加。

答案 2 :(得分:-1)

我们像透明背景一样使用此代码。

android:background="@android:color/transparent"