package com.qiyou.mb.android.utils;

import com.qiyou.mb.android.R;
import com.qiyou.mb.android.utils.image.QimageView;

import android.R.color;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

public class CompositDrawableView extends ScrollView{
	private final String TAG = "TextDrawableView";
	TextView tv = null;
	ImageView iv = null;
	RelativeLayout ll=null;
	public CompositDrawableView(Context context, String text,int width,int height) {
		super(context);
		 
		getTv(context,text,12);
		tv.setPadding(-5, -5, -5, 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 CompositDrawableView(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.setBackgroundColor(Color.RED);
		 getLL(context);
	 
//  	text="名称233445";
 		 
		
 		iv = new ImageView(context);
		
 		iv.setBackgroundResource(R.drawable.icon_arrowb);
 		iv.setRotation(bear-90);
//		image.setVisibility(View.GONE);
 		iv.setAlpha(150);
// 		iv.setLeft(50);
 		
		
		getTv(context,text,textSize);
//		tv.setBackgroundResource(getResources().getDrawable(R.drawable.icon_waypoint));
// 		tv.setBackgroundResource( R.drawable.icon_textbox);
//  		tv.setBackgroundResource( R.drawable.icon_pass);
//  		tv.setPadding(0, 50,0, 0);
//  		tv.setBackgroundColor(Color.RED);
		tv.setTextColor(Color.RED);
     	tv.setPadding(12, 2, 2, 2);
     	tv.setBottom(2);
// 		tv.setPadding(2, -5, -5, 6);
 		tv.setGravity(Gravity.CENTER);
// 		tv.setId(10);
// 		tv.setBackgroundColor(Color.GREEN);
// 		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
// 		ll.addView(tv,0, new android.view.ViewGroup.LayoutParams(width,height));
// 		this.addView(tv, new LayoutParams(   LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
 		ll.addView(tv,  new android.view.ViewGroup.LayoutParams(width,height));

// 		ll.addView(tv,  new android.view.ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
	    ll.addView(iv,  new android.view.ViewGroup.LayoutParams(   android.view.ViewGroup.LayoutParams.WRAP_CONTENT,android.view.ViewGroup.LayoutParams.WRAP_CONTENT));

 /*		if(bear<=180){
 			ll.addView(tv,  new android.view.ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
 			ll.addView(iv,  new android.view.ViewGroup.LayoutParams(   android.view.ViewGroup.LayoutParams.WRAP_CONTENT,android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
 		}else { 			
 			ll.addView(iv,  new android.view.ViewGroup.LayoutParams(   android.view.ViewGroup.LayoutParams.WRAP_CONTENT,android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
            ll.addView(tv, new android.view.ViewGroup.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));*/
// 		ll.addView(iv,1, new android.view.ViewGroup.LayoutParams(   android.view.ViewGroup.LayoutParams.WRAP_CONTENT,android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
// 		ll.addView(iv,1, new android.view.ViewGroup.LayoutParams(   android.view.ViewGroup.LayoutParams.MATCH_PARENT,android.view.ViewGroup.LayoutParams.MATCH_PARENT));
 	    
 		this.addView(ll);
	}
	void getLL(Context context){
		/*ll  = new LinearLayout( context);
		LinearLayout.LayoutParams linearParams = new LinearLayout.LayoutParams(
	            LayoutParams.MATCH_PARENT,
	            LayoutParams.MATCH_PARENT);
		ll.setLayoutParams(linearParams);
		ll.setOrientation(LinearLayout.HORIZONTAL);
 		ll.setBackgroundColor(Color.LTGRAY);*/
		
		ll  = new RelativeLayout( context);
		RelativeLayout.LayoutParams linearParams = new RelativeLayout.LayoutParams(
	            LayoutParams.MATCH_PARENT,
	            LayoutParams.MATCH_PARENT);
		ll.setLayoutParams(linearParams);		
 		ll.setBackgroundColor(Color.LTGRAY);
	}
	 
	void getTv(Context context, String text,int textSize){
		tv = new TextView(context);
		tv.setText(text);
		tv.setTextSize(textSize); 
		
		
		
	}
	
}
