Scale QR code size to 90% display width

pull/2/head
Marat Subkhankulov 7 years ago
parent 4de951e6e6
commit c0f4d9379e
  1. 12
      app/src/main/java/com/wallet/crypto/trustapp/views/RequestActivity.java
  2. 2
      app/src/main/res/layout/activity_request.xml

@ -4,11 +4,13 @@ import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Display;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
@ -28,11 +30,13 @@ import com.wallet.crypto.trustapp.model.VMAccount;
public class RequestActivity extends AppCompatActivity {
private static final String TAG = "REQUEST_ACTIVITY";
private static final double QR_CODE_WIDTH_RATIO = 0.9;
ImageView imageView;
Button copyButton;
TextView addressTextView;
public final static int QRcodeWidth = 500 ;
private int QRcodeWidth = 500;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -44,6 +48,12 @@ public class RequestActivity extends AppCompatActivity {
actionBar.setDisplayHomeAsUpEnabled(true);
}
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
QRcodeWidth = (int) (size.x * QR_CODE_WIDTH_RATIO);
Log.d("QR WIDTH", Integer.toString(QRcodeWidth));
imageView = (ImageView)findViewById(R.id.imageView);
addressTextView = (TextView)findViewById(R.id.addressTextView);
copyButton = findViewById(R.id.copy_button);

@ -18,7 +18,7 @@
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="500px"
android:layout_height="wrap_content"
android:id="@+id/imageView"
app:srcCompat="@drawable/ic_autorenew_black_24dp"
android:layout_centerHorizontal="true"

Loading…
Cancel
Save