【发布时间】:2017-05-25 13:40:33
【问题描述】:
在现实世界中,示例控制面板布局(如下)出现在其自己的 FrameLayout(片段容器)和(取决于应用程序是否在平板电脑上运行)旁边的地图,其颜色由触发的颜色选择器设置通过“颜色”按钮。 (注意:地图和控制面板有不同的背景。)
从颜色选择器返回时,关联的贴图粒子和按钮背景将更新为新颜色。
这个想法是(用户观察到的)按钮的颜色与地图完全匹配。
当然,它没有! (除非选择的颜色有 255-alpha)。
我知道这是“预期行为”,但是否有一个聪明的(或“hacky”)技巧可以消除父背景(仅限 Button 子元素后面),以便正确呈现子元素背景颜色?
示例控制面板布局和代码
<LinearLayout android:id="@+id/settingsLL"
android:orientation="vertical">
<LinearLayout android:id="@+id/oneOfMany"
android:orientation="horizontal">
<TextView style="@style/wptedit_title" android:text="[some title]" />
<Button style="@style/wptedit_color" android:id="@+id/colorBtn" />
</LinearLayout>
</LinearLayout>
// Control panel background
settingsLL.setBackgroundColor(0xFFD5FFDD);
// Faint red tint gives desired map background not reflected by button
colorBtn.setBackgroundColor(0x04FF0000);
【问题讨论】:
标签: android android-layout alpha-transparency