سؤال

I developed a native widget for Android 4.0.

Tha Layout is like this:

Framelayout <- alpha 0.7
  LinearLayout
    TextView
    ImageView <- alpha 1.0
    TextView

The main element is the image. I like to have the background of the widget transparent, but not the image. So I set alpha of the FrameLayout to 0.7 and alpha of the ImageView to 1.0 in the xml file. In the code I set the image with setImageViewBitmap.

Now the widget has some transparency like I wanted. But the Image has also some transparency. But I should be opaque. How can I set solve this?

هل كانت مفيدة؟

المحلول

Instead of using alpha(since it fades everything inside the parent) you can use background colour with transparency.

For 0.7 alpha, which means 70% white you can use (B3 is 70% value):

android:background="#B3FFFFFF"

So you will have a 30% transparent background and your ImageView will be visible as normal.

If you insist doing it by alpha, you must exlude your ImageView from the View which you set alpha value.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top