Java – Android – Set the background across 4 ImageViews

Android – Set the background across 4 ImageViews… here is a solution to the problem.

Android – Set the background across 4 ImageViews

How to achieve the effect of specifying a background part for each of the 4 Imageviews?
I want to get this effect :

WP 8.1 Home

Is there any way to do this?
Thank you.

Thanks @ChiefTwoPencil for your answer! Results achieved: Enter image description here

Thanks!

Solution

Quote the following code….

Create the XML file res/layout folder and place the following code.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/ic_launcher" >

<Button
    android:id="@+id/img1"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:background="@drawable/transibg"
    android:text="Button1" />

<Button
    android:id="@+id/img2"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_below="@id/img1"
    android:background="@drawable/transibg"
    android:text="Button2" />

</RelativeLayout>

Create XML files and code under the res/drawable folder, named transibg.xml.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="@android:color/transparent"/>
    <stroke android:color="@android:color/black" android:width="10dp"/>
</shape>

Then run the project. I hope you want this…

Related Problems and Solutions