мой код обмениваться имиджем без textView, который пользователь надел поверх изображения. Я хочу поделиться пригласительной картой через любое приложение (изображение и текст вместе). не только изображениекак обмениваться имиджем и текстом над ним в android
так что моя проблема заключается в том, чтобы разделить это изображение, название которого g7 и TextView, которые имеют удостоверение личности (tvView) над изображением
уведомление о том, что пользователь может изменить положение TextView по setOnTouchListener метод
()это мой g7.java код
public class g7 extends ActionBarActivity {
Button button;
TextView tvView ;
TextView red ;
TextView green ;
TextView blue ;
TextView yellow ;
TextView purple ;
TextView pink ;
TextView tv ;
float x,y = 0.0f ;
boolean moving = false ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.g7);
tvView = (TextView) findViewById(R.id.tvView) ;
red = (TextView) findViewById(R.id.red) ;
green = (TextView) findViewById(R.id.green) ;
blue = (TextView) findViewById(R.id.blue) ;
yellow = (TextView) findViewById(R.id.yellow) ;
purple = (TextView) findViewById(R.id.purple) ;
pink = (TextView) findViewById(R.id.pink) ;
Intent intent = getIntent();
String texx = intent.getStringExtra("fname") ;
tvView.setText(texx);
tvView.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View arg0 , MotionEvent arg1) {
switch (arg1.getAction())
{
case MotionEvent.ACTION_DOWN :
moving = true ;
break ;
case MotionEvent.ACTION_MOVE :
if (moving)
{
x = arg1.getRawX()- tvView.getWidth()/2 ;
y = arg1.getRawY() - tvView.getHeight() * 3/2 ;
tvView.setX(x) ;
tvView.setY(y) ;
}
break ;
case MotionEvent.ACTION_UP :
moving = false ;
break ;
}
return true;
}
});
red.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View arg2 , MotionEvent arg3) {
if (arg3.getAction() == MotionEvent.ACTION_DOWN) {
tvView.setTextColor(getResources().getColor(R.color.Red)) ;
}
return true;
}
});
green.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View arg2 , MotionEvent arg3) {
if (arg3.getAction() == MotionEvent.ACTION_DOWN) {
tvView.setTextColor(getResources().getColor(R.color.Green)) ;
}
return true;
}
});
blue.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View arg2 , MotionEvent arg3) {
if (arg3.getAction() == MotionEvent.ACTION_DOWN) {
tvView.setTextColor(getResources().getColor(R.color.Blue)) ;
}
return true;
}
});
yellow.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View arg2 , MotionEvent arg3) {
if (arg3.getAction() == MotionEvent.ACTION_DOWN) {
tvView.setTextColor(getResources().getColor(R.color.Yellow)) ;
}
return true;
}
});
purple.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View arg2 , MotionEvent arg3) {
if (arg3.getAction() == MotionEvent.ACTION_DOWN) {
tvView.setTextColor(getResources().getColor(R.color.Purple)) ;
}
return true;
}
});
pink.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View arg2 , MotionEvent arg3) {
if (arg3.getAction() == MotionEvent.ACTION_DOWN) {
tvView.setTextColor(getResources().getColor(R.color.Pink)) ;
}
return true;
}
});
}
@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;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
if (id == R.id.share)
{
PackageManager pm=getPackageManager();
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+"drawable/g7");
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Share via"));
return true;}
return super.onOptionsItemSelected(item);
}
}
и это мой файл XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<LinearLayout
android:id = "@+id/bottomlinear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".g7" >
<ImageView
android:id="@+id/g7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/g7" />
</LinearLayout >
<LinearLayout
android:id = "@+id/toplinear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".g7">
<TextView
android:id="@+id/tvView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tvv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text color :"
/>
<TextView
android:id="@+id/red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="red "
android:textColor="@color/Red" />
<TextView
android:id="@+id/green"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="green "
android:textColor="@color/Green" />
<TextView
android:id="@+id/blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="blue "
android:textColor="@color/Blue"/>
<TextView
android:id="@+id/yellow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="yellow "
android:textColor="@color/Yellow" />
<TextView
android:id="@+id/purple"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="purple "
android:textColor="@color/Purple"/>
<TextView
android:id="@+id/pink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="pink "
android:textColor="@color/Pink" />
</TableRow>
</TableLayout>
</LinearLayout>
</RelativeLayout>
должен написать сегмент кода для обмена изображения и textview вместе как пригласительный билет, и я не знаю, как! –