【问题标题】:How to set opacity for view(divider) and background如何设置视图(分隔线)和背景的不透明度
【发布时间】:2016-10-25 08:45:44
【问题描述】:

我想让分隔线的背景大约透明 20%,背景中有颜色(即浅灰色)? 下面是截图:

然后我就来到了这个link

但没有得到,如何为不透明度进行相同的处理。请帮忙

【问题讨论】:

  • 对你的上图进行不透明处理......比如 android:alpha="0.2"
  • 这对我有帮助,你能详细说明一下吗

标签: android android-layout background-color opacity


【解决方案1】:
Use frame layout as a main layout .It will overlaps your layout.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:background="#a8a3841a"
    >


    <LinearLayout
        android:id="@+id/wraper"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"

        android:background="#e7a3841a"
        android:orientation="horizontal">

        <View
            android:id="@+id/vwVerticalColourBar"
            android:layout_width="5dp"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical"
            android:background="@color/grey2"
            android:gravity="center_vertical"/>

        <TextView
            android:id="@+id/label"
            style="@style/item"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_marginLeft="8dp"
            android:gravity="left"/>

        <TextView
            android:id="@+id/label2"
            style="@style/subitem"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_marginLeft="8dp"
            android:gravity="left"/>
    </LinearLayout>

</FrameLayout>

希望对你有所帮助。

【讨论】:

  • 我不想要任何布局校正,对于不同的条件,我必须用深色视图显示不同的颜色,而且我有白色作为背景,就像你在你的框架布局中显示的那样。我的xml不完整,我只保留了有用的相关代码
猜你喜欢
  • 2013-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-08
  • 2012-07-27
  • 1970-01-01
相关资源
最近更新 更多