Android FrameLayout中的透明文本视图背景
我在FrameLayout中的ImageView上放置了一个TextView。我尝试过各种android的组合:文本视图背景,但总是能看到灰色背景。我想要一个透明的背景。android:background属性似乎被忽略了Android FrameLayout中的透明文本视图背景,android,background,textview,imageview,android-framelayout,Android,Background,Textview,Imageview,Android Framelayout,我在FrameLayout中的ImageView上放置了一个TextView。我尝试过各种android的组合:文本视图背景,但总是能看到灰色背景。我想要一个透明的背景。android:background属性似乎被忽略了 <HorizontalScrollView android:id="@+id/categories_horizontal_scrollview" android:layout_width="wrap_content" android:layout
<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>
.
.
使用以下命令:
TextView tv;
tv.setBackgroundColor(0xXX??????);
其中XX-[00;FF]-资产负债表一些数字是原色的
希望有帮助正如布雷登指出的那样,布局中存在问题。最后,我将ImageView和TextView作为单个资源放入框架布局中,然后在需要的地方动态添加它们。我们在透明背景中使用类似的代码
android:background="@android:color/transparent"
如果您试图在文本视图后面使用图像,为什么不将图像设置为文本视图的背景呢?使用android:backround=@drawable/photos\u ipadAlso,尝试在文本视图上使用android内置的透明背景颜色android:background=@android:color/transparency您的文本视图不在imageview上…我尝试了android:background=android:color/transparency,它不起作用。我做framelayout的原因是我需要文本在图片的底部。如果它不起作用,到底发生了什么?这可能与您的滚动视图有关。我会先制作一个测试应用程序,它只有框架布局和imageview/textview。看看透明度是否有效。然后添加线性布局。然后是滚动视图。看看你是否能找出问题出在哪里。你可以在上面看到,他已经将android:background设置为00000000,这与你的建议是一样的,只是以编程方式而不是XML。是的,我同意应该这样做。但我认为问题不在于挫折。我想这就是他的布局层次。