androidplot:在图表上插入徽标

时间:2014-09-29 06:46:35

标签: android bitmap androidplot

我想在androidplot图上添加一个徽标,或者通常是一个或多个位图。 我认为解决方案是将androidplot图转换为位图,然后在上面添加其他位图。 但是这个解决方案并不好,因为将图形转换为位图我会失去图形的质量。 理想的是不会转换成位图。有人能帮我吗? 感谢

1 个答案:

答案 0 :(得分:0)

为此目的使用 FrameLayout

Add your graph xml code in FrameLayout and Add another ImageView or Button or what ever you like in FrameLayout

我将ImageView放在图表的右下角。你可以改变它。

  1. XML代码

    <FrameLayout
            android:id="@+id/frame_for_graph"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
    
            <com.androidplot.xy.XYPlot
                    android:id="@+id/mySimpleXYPlot"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    title="Stats" />
    
            <ImageView
                    android:id="@+id/iv_Logo"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_marginBottom="20dp"
                    android:layout_gravity="right|bottom"
                    android:src="@drawable/ic_launcher" />
    </FrameLayout>
    
  2. 徽标的Java代码

    ImageView logo = (ImageView) findViewById(R.id.iv_Logo);
    
    logo.setOnClickListener(new OnClickListener() {
    
        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Toast.makeText(getApplicationContext(), "Logo Clicked",
                    Toast.LENGTH_LONG).show();
            //Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("YOUR COMPANY URL"));
            //startActivity(browserIntent);
        }
    });
    
  3. 快照:

    Snap