I need to place the button(green) at the place shown on the image(red).
It should be the same for all kind of phone screens in portrait mode.
This is the middle of the screen but the height is changing according to the screen size. These are the properties of the button. android:layout_marginBottom is not true for all screens sizes.
Button
<ImageView
android:id="#+id/circle_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="100dp"
app:srcCompat="#drawable/circle" />
Irregular shape
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:adjustViewBounds="true"
android:src="#drawable/irregular_shape" />
Wanted result
One of the ways to solve this is to separate your irregular shape into two shapes, and than place the button between the shapes with ConstraintLayout, something like this:
shapes image
And the code would be something like this:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/shape2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/shape_bank_bill_dotted_transparent"
app:layout_constraintBottom_toTopOf="#+id/shape1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="#+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/shape1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="#+id/shape1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/shape_bank_bill_dotted_transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
Related
!!Beginner alert!!
I designed my app in Adobe XD. Now I started to introduce the design in Android Studio. However, whenever I use a resource from the resource manager and drop it in the designer, the resizable area is way bigger than the image which i think will affect the clickable area of it. Everything looks good in Adobe XD, the resizable area is the border of the button. How can I do this in Android Studio? I will attach images below. Help is greatly appreciated.
How it's supposed to look (the look in Adobe XD)
The resizable area of the button in Adobe XD
The resizable area of the button in Android Studio
How can I make Android Studio have the same resizable area as Adobe XD?
I implemented the XML code below:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
tools:context=".Dashboard">
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toStartOf="#+id/imageView5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/resmonevo" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
app:layout_constraintStart_toStartOf="#+id/imageView3"
app:layout_constraintTop_toBottomOf="#+id/imageView3"
app:srcCompat="#drawable/red_gradient_line" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="121dp"
app:layout_constraintBottom_toBottomOf="#+id/imageView3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView3"
app:layout_constraintTop_toTopOf="#+id/imageView3"
app:srcCompat="#drawable/dashboard" />
<ImageView
android:id="#+id/imageView14"
android:layout_width="0dp"
android:layout_height="115dp"
android:layout_marginStart="5dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView4"
app:srcCompat="#drawable/rectangle_210" />
<ImageView
android:id="#+id/imageView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/imageView18"
app:srcCompat="#drawable/rectangle_221" />
<ImageView
android:id="#+id/imageView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginBottom="1dp"
app:layout_constraintBottom_toTopOf="#+id/textView2"
app:layout_constraintStart_toEndOf="#+id/imageView15"
app:srcCompat="#drawable/welcome_" />
<ImageView
android:id="#+id/imageView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="47dp"
android:layout_marginEnd="27dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/imageView14"
app:srcCompat="#drawable/how_are_you_today" />
<ImageView
android:id="#+id/imageView20"
android:layout_width="21dp"
android:layout_height="19dp"
app:layout_constraintBottom_toBottomOf="#+id/imageView15"
app:layout_constraintEnd_toEndOf="#+id/imageView15"
app:layout_constraintStart_toStartOf="#+id/imageView15"
app:layout_constraintTop_toTopOf="#+id/imageView15"
app:srcCompat="#drawable/ic_person_outline_24px" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_marginEnd="9dp"
android:fontFamily="#font/montserrat"
android:text="Username"
android:textColor="#FFFFFF"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="#+id/imageView19"
app:layout_constraintEnd_toStartOf="#+id/imageView19"
app:layout_constraintStart_toStartOf="#+id/imageView18"
app:layout_constraintTop_toBottomOf="#+id/imageView19" />
<ImageView
android:id="#+id/imageView8"
android:layout_width="390dp"
android:layout_height="351dp"
android:adjustViewBounds="true"
app:srcCompat="#drawable/rectangle_187"
tools:layout_editor_absoluteX="-39dp"
tools:layout_editor_absoluteY="158dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
The XML code for the most recent button is :
<ImageView
android:id="#+id/imageView8"
android:layout_width="390dp"
android:layout_height="351dp"
android:adjustViewBounds="true"
app:srcCompat="#drawable/rectangle_187"
tools:layout_editor_absoluteX="-39dp"
tools:layout_editor_absoluteY="158dp" />
Here is how my mess looks
The problem what I can figure out is that you are using static size in width
I will suggest you to use Linear layout as parent and inside it have a Image view as child because you are statically defining the width of image view.
so try something like this:
Kindly use imageView in your case I have used MaterialTextView just for an instance
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:orientation="horizontal"
android:padding="12dp">
<com.google.android.material.textview.MaterialTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:fontFamily="#font/cantata_one"
android:text="Email"/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.7"
android:id="#+id/layout_recycler_all_cust_email"
android:fontFamily="#font/capriola"
android:textColor="#706E6E"
android:text="Email "/>
</LinearLayout>
and in the above code, you can see i have assigned weightsum to the LinearLayout and accordingly wait to it's children so you should try this. This will make your UI Flexible according to the device size and in the android:layout_height="wrap_content" you can use your value like 350DP or something else.
I need to make my splash screen fit all the devices. It works perfect on nexus but on other device the animation is a little bit different. Here is my splash screen activity. I think the problem is that axes Y and X will work different on other device
logo = findViewById(R.id.logo);
splashImg = findViewById(R.id.img);
lottieAnimationView = findViewById(R.id.lottie);
splashImg.animate().translationY(-2000).setDuration(1000).setStartDelay(4000);
logo.animate().translationY(1100).setDuration(1000).setStartDelay(4000);
lottieAnimationView.animate().translationY(1400).setDuration(1000).setStartDelay(4000);
and in the splash XML
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:layout_conversion_absoluteHeight="731dp"
tools:layout_conversion_absoluteWidth="411dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" >
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="#+id/img"
android:layout_width="wrap_content"
android:layout_height="900dp"
android:src="#drawable/shafaqat"
app:layout_constraintVertical_bias="0"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<ImageView
android:id="#+id/logo"
android:layout_width="300dp"
android:layout_height="300dp"
android:src="#drawable/logo"
app:layout_constraintVertical_bias=".1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<com.airbnb.lottie.LottieAnimationView
android:id="#+id/lottie"
app:lottie_autoPlay="true"
android:layout_width="wrap_content"
android:layout_height="200dp"
app:layout_constraintVertical_bias="0"
app:lottie_rawRes="#raw/splash"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/logo" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
i would use weights and fill content views
if i want to all screen view, use fill-content in size attribute, and if you want your logo in the center, i used views with height attribute to spacing like bootstrap
i would put three views and each one with the same weight, and in the middle view i would put the image view with fill-content size, this is my way to make responsive views with the same resource keeping proportions
this is an example about how to use weights
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="5">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="2" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3" />
Seems silly but I have tried using ImageButton, Image view but the black square behind circular image is not going. I am using png image and want transparent background.
I have attached the expected output, layout view in android and real device but look very different and nothing seems to work
Expected result
Actual result
Drawable Resource Image
Edited Code XML Layout. Reset other views are fine
Layout Image
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".view.fragments.DashboardFragment">
<ImageView
android:id="#+id/iv_dashboard"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitXY"
android:src="#drawable/bg_dashboard"
app:layout_constraintBottom_toTopOf="#+id/guide_horizontal_30"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- background image resource -->
<TextView
android:id="#+id/txtFromDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/from_date"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/iv_dashboard" />
<TextView
android:id="#+id/tvFromDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_10dp"
android:text="Date"
android:drawableBottom="#drawable/dashboard_bottom_blue"
app:layout_constraintEnd_toStartOf="#+id/guide_vertical_40"
app:layout_constraintStart_toStartOf="#+id/txtFromDate"
app:layout_constraintTop_toBottomOf="#+id/txtFromDate" />
<TextView
android:id="#+id/txtToDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_5dp"
android:text="#string/to_date"
app:layout_constraintBaseline_toBaselineOf="#+id/txtFromDate"
app:layout_constraintStart_toEndOf="#+id/guide_vertical_40" />
<TextView
android:id="#+id/tvToDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Date"
android:paddingTop="#dimen/margin_2dp"
android:paddingBottom="#dimen/margin_2dp"
app:layout_constraintBaseline_toBaselineOf="#+id/tvFromDate"
app:layout_constraintEnd_toStartOf="#+id/guide_vertical_80"
app:layout_constraintStart_toStartOf="#+id/txtToDate" />
<!-- problematic image view-->
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/btnGo"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="#drawable/btn_search"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintBottom_toBottomOf="#+id/tvToDate"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/guide_vertical_80"
app:layout_constraintTop_toTopOf="#+id/txtToDate" />
</androidx.constraintlayout.widget.ConstraintLayout>
use this if you don't want black background just remove background from layout.
<android.support.v7.widget.AppCompatImageView
android:id="#+id/btn_key"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/black"
android:src="#drawable/img_key"
/>
I was having the same issue with my image and what I just did is to change the Background of the imageView and make it Transparent.
<ImageView
android:id="#+id/iv_dashboard"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitXY"
android:background="#android:color/transparent"
android:src="#drawable/bg_dashboard"
app:layout_constraintBottom_toTopOf="#+id/guide_horizontal_30"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
I have an imageview and I want to place a button for closing/deleting the image from the imageView just like it's done on Tinder profile pics. The problem is that it's always placed behind it not matter what I do.
I have a RelativeLayout as container for the imageview and imagebutton
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:id="#+id/close1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_close"
android:background="#color/white"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" />
<ImageView
android:id="#+id/photo1"
android:layout_width="match_parent"
android:layout_height="115dp"
android:layout_marginHorizontal="5dp"
android:background="#drawable/rounded_rect_primary"
android:elevation="5dp"
android:scaleType="fitXY"
android:src="#drawable/icon_upload" />
</RelativeLayout>
I've tried something like this too:
close1.bringToFront();
close2.bringToFront();
close3.bringToFront();
I'd like to understand how it works, what exactly defines what comes in front and behind?
Your button always shown behind the image because Android render the XML code from top to bottom. So your button get rendered first, then it get overlay by image.
You should try to put ImageButton after ImageView. And i recommend you to use ConstraintLayout
It should be like this.
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/photo1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/rounded_rect_primary"
android:scaleType="fitXY"
android:src="#drawable/icon_upload"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<ImageButton
android:id="#+id/close1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_close"
android:background="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
I am using a Relative Layout and am very confused why the layout is so different: the EditText is so close to the second spinner, the second spinner is a little to the left, not aligned to the one above it, even though they both have the same marginStart; also, the button should be centered horizontally.
I've read that the actual phone screen might differ from the view I see in Android Studio but how does that affect the marginStart which is the same for those two spinners?!
Is it something that I do wrong? (I am a beginner in developing with Android Studio). Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".QuizzesFragment">
<Spinner
android:id="#+id/fragquizzes_spn_courses"
android:layout_width="286dp"
android:layout_height="85dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="71dp"
android:layout_marginTop="225dp"
android:entries="#array/courses_array" />
<Spinner
android:id="#+id/fragquizzes_spn_departments"
android:layout_width="286dp"
android:layout_height="85dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="71dp"
android:layout_marginTop="123dp"
android:entries="#array/depts_array" />
<Button
android:id="#+id/fragquizzes_btn_createQuiz"
android:layout_width="126dp"
android:layout_height="63dp"
android:layout_alignBottom="#id/fragquizzes_spn_courses"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginStart="-90dp"
android:layout_marginTop="22dp"
android:layout_marginEnd="137dp"
android:layout_marginBottom="70dp"
android:text="#string/create_quiz" />
<EditText
android:id="#+id/fragquizzes_et_quizname"
android:layout_width="250dp"
android:layout_height="64dp"
android:layout_alignBottom="#+id/fragquizzes_spn_courses"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="70dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="162dp"
android:ems="10"
android:inputType="text"
android:hint="quiz name"/>
</RelativeLayout>
I would like to have the same view on the phone or at least something similar?
These are the screenshots:
![design view] https://imgur.com/a/bGBm4YW
![actual device] https://imgur.com/a/9KaghT4
The reason that your layout is not responsive is that you are using fixed size on your views (android:layout_width="286dp" and android:layout_height="85dp" for example).
Because different phones got different screen sizes if you will use fixed size in dp your layout may look good on one device but won't look good on other devices with different screen size.
"how does that affect the marginStart which is the same for those two spinners" - well again - you use fixed size so it won`t be responsive to all screen sizes.
If you want your layout to be responsive to all screen either don't use fixed size/use fixed size but create 1 layout for every screen size or what I think is the most easy solution - use ConstraintLayout, it is super easy to use, super fast to create your layout and it will be responsive to all screen sizes.
Here is an example using constraintLayout with some guidelines to achieve your desired layout:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Spinner
android:id="#+id/some"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/editText"
app:layout_constraintEnd_toEndOf="#+id/spinner2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/spinner2"
app:layout_constraintTop_toBottomOf="#+id/spinner2" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="395dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="#+id/some"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="spread" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText"
tools:text="button" />
<EditText
android:id="#+id/editText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="#+id/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/guideline3"
app:layout_constraintVertical_chainStyle="spread" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5" />
</androidx.constraintlayout.widget.ConstraintLayout>
Please try below layout file. Let me know if it is useful or not. If you need any further help regarding your layout feel free to ask.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Spinner
android:id="#+id/fragquizzes_spn_departments"
android:layout_width="match_parent"
android:layout_height="85dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="70dp"
android:layout_marginTop="123dp"
android:layout_marginEnd="70dp"
android:entries="#array/depts_array" />
<Spinner
android:id="#+id/fragquizzes_spn_courses"
android:layout_width="match_parent"
android:layout_height="85dp"
android:layout_below="#+id/fragquizzes_spn_departments"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="70dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="70dp"
android:entries="#array/courses_array" />
<EditText
android:id="#+id/fragquizzes_et_quizname"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_above="#+id/fragquizzes_btn_createQuiz"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="70dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="70dp"
android:layout_marginBottom="30dp"
android:ems="10"
android:hint="quiz name"
android:inputType="text" />
<Button
android:id="#+id/fragquizzes_btn_createQuiz"
android:layout_width="126dp"
android:layout_height="63dp"
android:layout_alignBottom="#id/fragquizzes_spn_courses"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="70dp"
android:text="#string/create_quiz" />
</RelativeLayout>
Plz try this code.
In this code we use spinner height and width not fix, so in all frame it fill fit.
we use LinearLayout for set spinner, edittext and button on fix layout. We use android:orientation="vertical" so all field inside this layout show on vertical.
Upper spinner margin you set according to your choice.
I set margin left and Right in linearlayout so all field automatic adjust according to this layout.
I hope its very helpful to design layout according to your.
Thanku..