简体   繁体   中英

How do I can add a box show the image I click and eraser

how can I do something like this box show in all activity in my app, and when I press any image in my app the image show in this box, any one can help me with this

the image

well in android xml layout there is no box shadow attribute, thats why we use border or stroke, or you can create 2 boxes on top of each other with a little displacement to create shadow look, using layer-list this is boxshadow.xml drawable xml file, saved in res/drawable folder :

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item  >
        <shape>
            <corners android:radius="10dip" />
            <gradient
                android:angle="0"
                android:endColor="#cccccc"
                android:startColor="#4c4c4c" />
        </shape>
    </item>
    <item android:bottom="3dp" android:right="3dp" android:left="3dp" android:top="3dp" >
        <shape>
            <corners android:radius="10dip" />
            <gradient
                android:angle="270"
                android:centerColor="#f8d79b"
                android:centerY="0.5"
                android:endColor="#f8d79b"
                android:startColor="#f8d79b" />
        </shape>
    </item>

</layer-list>

this is just an example and here is the result for this shape:

在此处输入图片说明

I used the xml file as background for a button in the activitylayout.xml like this:

 <Button
        android:layout_width="90dp"
        android:layout_height="wrap_content"
        android:text="Back"
        android:id="@+id/button_back"
        android:background="@drawable/boxshadow" />

of course you can use the same boxshadow.xml as a background for any other element such as TextView, EditText or ImageView.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM