code to add rounded border to QRImage ,through xml file(below code used in my JOR-Project),in Android

Here iam generating and displaying QR-image ,and that image will added to Bitmap and that bitmap will be added to ImageView,in my JOR-Project.. 


TrafficcaseDetailsScreen.java:
 b = Bitmap.createBitmap( 300, 320, Bitmap.Config.ARGB_8888);              
                Canvas c = new Canvas(b);
                //v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
                view.draw(c); 
              
          
            //traffic_case_qr_image.addView(view,p);
          
            ImageView qrPri=(ImageView)findViewById(R.id.qrImagePre);
            if(null!=qrPri){
            qrPri.setImageBitmap(b);
            }
        }


trafficcasedetails_screen.xml:
  <LinearLayout
                    android:layout_width="180dip"
                    android:layout_height="220dip"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentTop="true"
                    android:layout_marginLeft="25dip"
                    android:layout_marginTop="25dip"
                    android:background="@drawable/rounded_border" >

                    <ImageView
                        android:id="@+id/qrImagePre"
                        android:layout_width="200dip"
                        android:layout_height="250dip"
                        android:contentDescription="content description"
                        android:scaleType="fitXY"
                        android:visibility="visible" />
                </LinearLayout>

rounded_border.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke android:width="2dp" android:color="#30000000" />
    <solid android:color="@color/White"/>
    <padding android:left="2dp" android:top="2dp"
            android:right="2dp" android:bottom="2dp" />
      <gradient
    android:startColor="@color/White"
    android:endColor="@color/White"
    android:angle="270"/>     
    <corners android:radius="8dp" />
</shape>


Comments

Popular posts from this blog

Custom Dialog with no title and full screen in Android

code to display .pdf,.text,.DOC,.DOCX,.doc extension files exists in SDCard

Best working code to set Date limits on Date Picker Dialog,in Android