【问题标题】:Semi-transparent Fragment with opaque buttons带有不透明按钮的半透明片段
【发布时间】:2015-11-19 00:36:19
【问题描述】:

我需要用不透明(粗体)按钮实例化半透明Fragment

我正在尝试使用 alpha 管理 Fragment 透明度,例如:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/templateListLayout"
    android:orientation="vertical"
    android:alpha="0.5"
    >
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fabCustom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:visibility="visible"
        app:elevation="4dp"
        app:borderWidth="1dp"
        app:fabSize="mini"
        android:layout_marginRight="24dp"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="5dp"
        android:layout_above="@id/anchor"
        android:layout_alignParentRight="true"
        android:alpha="1.0"
        />
    <View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:id="@+id/anchor"
        android:background="#000000"
        android:visibility="invisible"
        android:layout_alignParentBottom="true"
        />
</RelativeLayout>

但是没用,Fragment 也用按钮变成半透明的。但我需要按钮不透明。

片段创建为:

Fragment fragment = SelectTemplateFragment.newInstance();
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, fragment).addToBackStack(null).commit();

有什么想法吗?

【问题讨论】:

    标签: android android-fragments transparency opacity


    【解决方案1】:

    子视图继承 alpha 值。而是尝试将背景放置为具有所需 alpha 的按钮的兄弟。比“上面”的按钮。

    <RelativeLayout>
        <LinearLayout>
           Fill parent and alpha = X
        </LinearLayout>
        <Button>
           Placed wherever and alpha = 1
        </Button>
    </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 2011-09-15
      • 1970-01-01
      • 2021-09-18
      • 2015-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-31
      • 2014-01-05
      相关资源
      最近更新 更多