簡體   English   中英

如何在 imageview 和 relativelayout 中設置 alpha

[英]How to set alpha in imageview and relativelayout

在此處輸入圖像描述

這是我的 xml 代碼。如果有人知道正確的方法,請告訴我。 單擊它后,我想在相對布局的邊緣放置一個刻度圖像。但是當我單擊它時,圖像上的邊框藍線

 <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30sp"
            android:layout_marginBottom="2dp">

            <RelativeLayout
                android:id="@+id/lessTwo"
                android:layout_width="match_parent"
                android:layout_height="48sp"
                android:layout_marginLeft="40sp"
                android:layout_marginTop="10dp"
                android:layout_marginRight="39sp"
                android:background="@drawable/border_blue">


                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_alignParentLeft="true"
                    android:background="@null"
                    android:fontFamily="@font/lato_light"
                    android:hint="New Stager (less than 2 year)"
                    android:paddingLeft="16sp"
                    android:paddingTop="14sp"
                    android:paddingRight="16sp"
                    android:paddingBottom="14sp"
                    android:singleLine="true"
                    android:textColorHint="@color/editColor"
                    android:textSize="15sp" />


            </RelativeLayout>

            <ImageView
                android:id="@+id/lessTwoIcon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="30dp"
                android:alpha="10"
                android:src="@drawable/ic_check"
                android:visibility="visible" />

        </RelativeLayout>
I hoep this code help you.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="30sp"
        android:layout_marginBottom="2dp">

        <RelativeLayout
            android:id="@+id/lessTwo"
            android:layout_width="match_parent"
            android:layout_height="48sp"
            android:layout_marginLeft="40sp"
            android:layout_marginTop="10dp"
            android:layout_marginRight="39sp"
            android:background="@drawable/border_blue">


            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentLeft="true"
                android:background="@null"
                android:hint="New Stager (less than 2 year)"
                android:paddingLeft="16sp"
                android:paddingTop="14sp"
                android:paddingRight="16sp"
                android:paddingBottom="14sp"
                android:singleLine="true"
                android:textSize="15sp" />


        </RelativeLayout>

        <ImageView
            android:id="@+id/lessTwoIcon"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_alignParentRight="true"
            android:layout_marginRight="30dp"
            android:alpha="10"
            android:layout_alignTop="@id/lessTwo"// add this line
            android:src="@drawable/icon_profile"
            android:visibility="visible" />

    </RelativeLayout>

</LinearLayout>

為您的 ImageView 添加背景。

              <ImageView
                android:id="@+id/lessTwoIcon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="30dp"
                android:alpha="1"
                android:background="#ffffff"
                android:src="@drawable/ic_check"
                android:visibility="visible" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM