Reputation: 95
I am currently trying to get some kind of dynamic credit card picture, but what I want is to be able to set the numbers and the creditcard, which is an imageview. Now I need my textview to be at the same location for all screensizes, but I have trouble achieving this.
Can anyone point me in the right direction? Or maybe share a better way with me? This is what I got now:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:padding="10dp">
<ImageView
android:id="@+id/creditcardimage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
app:srcCompat="@drawable/creditcardblue"/>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/creditcardimage"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="81dp"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:text="1234 5678 9876 5432"
android:textSize="20sp"/>
Here is an image of the idea:
Thanks!
Upvotes: 2
Views: 140
Reputation: 3430
You can follow the following steps
You can also set adjustViewBonds and other properties so that the aspect ratio of the imageview doesnt change.
Upvotes: 1