package com.qiyou.mb.android.utils;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class TextDrawableView extends LinearLayout{
	private final String TAG = "TextDrawableView";
	TextView tv = null;
	ImageView iv = null;
	public TextDrawableView(Context context, String text,int width,int height) {
		super(context);
		this.setOrientation(VERTICAL);
		getTv(context,text,12);
//		tv.setPadding(-5.0, -5.0, -5.0, 2);
		tv.setBackgroundColor(Color.RED);
		tv.setTextColor(Color.WHITE);
		tv.setGravity(Gravity.CENTER);
		this.addView(tv, new LayoutParams(width,height));
	}

	/*
	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	public TextDrawableView(Context context, String text,int textSize,boolean hasMsg,float bear,int width,int height) {
		super(context);
		 
	*//*	 LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    	 View layout = inflater.inflate(R.layout.live_share_point,
    	                                (ViewGroup) this);
    	 ImageView image = (ImageView) layout.findViewById(R.id.img_direction); 
    	 image.setBackgroundResource(R.drawable.icon_play);
 		image.setRotation(bear);
  		image.setAlpha(150);
    	 TextView tv = (TextView) layout.findViewById(R.id.txt_name);
    	 tv.setBackgroundResource( R.drawable.icon_textbox);
 		tv.setTextColor(Color.RED);
  		tv.setPadding(2, -5, -5, 6);
  		tv.setGravity(Gravity.CENTER);
  		*//*
  		
  		
	 this.setOrientation(LinearLayout.VERTICAL);
 		this.setBackgroundColor(color.holo_purple);
 		 
		
		ImageView image = new ImageView(context);
		
		image.setBackgroundResource(R.drawable.icon_play);
		image.setRotation(bear);
//		image.setVisibility(View.GONE);
		image.setAlpha(150);
		image.setId(10);
 
		
		getTv(context,text,textSize);
//		tv.setBackgroundResource(getResources().getDrawable(R.drawable.icon_waypoint));
// 		tv.setBackgroundResource( R.drawable.icon_textbox);
		tv.setTextColor(Color.RED);
 		tv.setPadding(2.0, -5.0, -5.0, 6.0);
 		tv.setGravity(Gravity.CENTER);
 		tv.setId(10);
 		tv.setCompoundDrawables( getResources().getDrawable(R.drawable.icon_pass),null, null  ,null);

// 		tv.setRotation(bear);
// 		Drawable d =getResources().getDrawable(R.drawable.icon_waypoint);
// 		tv.setTextColor(Color.GREEN);
// 		tv.setCompoundDrawables( getResources().getDrawable(R.drawable.icon_pass),null, null  ,null);
// 		android.view.ViewGroup.LayoutParams
 		this.addView(tv,0, new android.view.ViewGroup.LayoutParams(width,height));
// 		this.addView(tv, new LayoutParams(   LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
*//* 		TextView msg = new TextView(context);
 		msg.setText("something to say");
 		msg.setBackgroundResource(R.drawable.icon_waypoint);
 		this.addView(msg, new LayoutParams(   LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));*//*
 		this.addView(image,1, new android.view.ViewGroup.LayoutParams(   android.view.ViewGroup.LayoutParams.WRAP_CONTENT,android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
 	    
 		
	}
	*/
	public void reWriteText(String text){
		tv.setText(text);
	}
	
	public String getText(){
		return tv.getText().toString();
	}
	
	public void reWriteText(String text,int width,int height){
		tv.setText(text);
		this.addView(tv, new LayoutParams(width, height));
	}
	
	void getTv(Context context, String text,int textSize){
		tv = new TextView(context);
		tv.setText(text);
		tv.setTextSize(textSize); 
		
		
		
	}
	
}
