EDIT: I'm changing my question a bit, to fit what I think actually has to happen now. I believe I need to make my image glow. I found this resource: how to make glow effect in my images? but on IRC some users didn't think it was the best idea, but couldn't provide an alternative.
I'm trying to make a pretty complex little app, but one of the first requirements is to show the user that an imageView is selected. When the white space is selected, it should "de-select" the imageView.
How do I show that an item is selected? Right now I'm trying to show a border around my image, using padding and a background color, but this doesn't work if the image has transparency. I saw in another very similar SO question that you can use a frame and wrap each imageView inside of it, but if my background is a pattern, then this won't work. My next attempt would be to create a custom imageView and set this as a property. I've heard to maybe use openGL or something, but I have no experience at all with that. What would be the best option in this situation?
Here is my MainActivity:
package com.example.draggingactivity;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
public class MainActivity extends Activity {
ImageView imageView1;
ImageView imageView2;
ImageView imageView3;
ImageView imageView4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView1 = (ImageView) findViewById(R.id.imageView1);
imageView2 = (ImageView) findViewById(R.id.imageView2);
imageView3 = (ImageView) findViewById(R.id.imageView3);
imageView4 = (ImageView) findViewById(R.id.imageView4);
imageView1.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
FrameLayout parent = (FrameLayout) v.getParent();
parent.setBackgroundColor(Color.RED);
return false;
}
});
imageView2.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
FrameLayout parent = (FrameLayout) v.getParent();
parent.setBackgroundColor(Color.RED);
return false;
}
});
imageView3.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
FrameLayout parent = (FrameLayout) v.getParent();
parent.setBackgroundColor(Color.RED);
return false;
}
});
imageView4.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
FrameLayout parent = (FrameLayout) v.getParent();
parent.setBackgroundColor(Color.RED);
return false;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dp" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="1dp"
android:src="@drawable/ic_launcher" />
</FrameLayout>
<FrameLayout
android:id="@+id/frameLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="1dp" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:padding="1dp" >
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="1dp"
android:src="@drawable/ic_launcher" />
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/frameLayout1"
android:padding="1dp" >
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="1dp"
android:src="@drawable/ic_launcher" />
</FrameLayout>
</RelativeLayout>
EDIT: In the end of this project I want to sort of replicate what the layout editor in eclipse in my app. So the user can "click" on a view, and see that it is the current view that is being worked on.