Java 向用户显示已使用斯托克/轮廓/辉光“选择”图像视图?
编辑:我将我的问题稍作修改,以适应我认为现在必须发生的事情。我相信我需要让我的形象焕发光彩。我找到了这个资源:但在IRC上,一些用户认为这不是最好的主意,但无法提供替代方案 我正在尝试制作一个非常复杂的小应用程序,但首要要求之一是向用户显示已选择imageView。选择空白时,应取消选择imageView 如何显示已选中项目?现在,我正试图使用填充和背景色在图像周围显示边框,但如果图像具有透明度,这将不起作用。我在另一个非常类似的问题中看到,你可以使用一个框架并将每个imageView包装在其中,但如果我的背景是一个模式,那么这将不起作用。我的下一个尝试是创建自定义imageView并将其设置为属性。我听说可能会使用openGL或其他东西,但我对此毫无经验。在这种情况下,什么是最好的选择 以下是我的主要活动:Java 向用户显示已使用斯托克/轮廓/辉光“选择”图像视图?,java,android,android-layout,opengl-es,android-imageview,Java,Android,Android Layout,Opengl Es,Android Imageview,编辑:我将我的问题稍作修改,以适应我认为现在必须发生的事情。我相信我需要让我的形象焕发光彩。我找到了这个资源:但在IRC上,一些用户认为这不是最好的主意,但无法提供替代方案 我正在尝试制作一个非常复杂的小应用程序,但首要要求之一是向用户显示已选择imageView。选择空白时,应取消选择imageView 如何显示已选中项目?现在,我正试图使用填充和背景色在图像周围显示边框,但如果图像具有透明度,这将不起作用。我在另一个非常类似的问题中看到,你可以使用一个框架并将每个imageView包装在其中
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:
编辑:在这个项目的最后,我想在我的应用程序中复制eclipse中的布局编辑器。因此,用户可以单击某个视图,并查看正在处理的是当前视图
<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>