Created
October 23, 2020 09:06
-
-
Save prasad-333/e8d2c94c93a5f48baa5c2b534ace8b09 to your computer and use it in GitHub Desktop.
Spinner alignment can be done to parent, its just need to repeat margins on second one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"> | |
<ImageView | |
android:id="@+id/imageView" | |
android:layout_width="match_parent" | |
android:layout_height="265dp" | |
android:scaleType="fitXY" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.0" | |
tools:ignore="ContentDescription" /> | |
<!-- app:srcCompat="@mipmap/comment"--> | |
<ImageButton | |
android:id="@+id/commentButton" | |
android:layout_width="100dp" | |
android:layout_height="50dp" | |
android:background="@null" | |
android:contentDescription="comment_Button" | |
android:scaleType="fitCenter" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.0" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.87" /> | |
<TextView | |
android:id="@+id/textView2" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="comment" | |
android:textSize="18dp" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.025" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.8" /> | |
<!-- android:background="@drawable/custom_button"--> | |
<!-- android:text="@string/order_Button"--> | |
<Button | |
android:id="@+id/ordering_button" | |
android:layout_width="163dp" | |
android:layout_height="72dp" | |
android:textAllCaps="false" | |
android:textColor="#121212" | |
android:textSize="25sp" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.5" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.885" /> | |
<!-- app:menu="@menu/bottom_navigation"--> | |
<!-- android:background="@color/colorGreen"--> | |
<com.google.android.material.bottomnavigation.BottomNavigationView | |
android:id="@+id/bottom_navigation" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
app:itemIconTint="@color/colorPrimaryDark" | |
app:itemTextColor="@color/colorAccent" | |
app:labelVisibilityMode="labeled" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" /> | |
<TextView | |
android:id="@+id/tvName" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:gravity="center" | |
android:textColor="#000000" | |
android:textSize="29sp" | |
android:textStyle="bold" | |
app:fontFamily="casual" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.489" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.41" /> | |
<!-- android:text="@string/size"--> | |
<TextView | |
android:id="@+id/textViewS" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:textColor="#000000" | |
android:textSize="20sp" | |
android:textStyle="bold" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.025" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.481" /> | |
<!-- android:text="TextViewB"--> | |
<TextView | |
android:id="@+id/textViewB" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:textColor="#000000" | |
android:textSize="20sp" | |
android:textStyle="bold" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.025" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.642" /><![CDATA[ | |
/> | |
]]> | |
<RadioGroup | |
android:id="@+id/radioGroup_Size" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:orientation="horizontal" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.862" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.485"> | |
<!-- android:background="@drawable/background_selector"--> | |
<!-- android:text="@string/small"--> | |
<!-- android:textColor="@drawable/text_selector"--> | |
<RadioButton | |
android:id="@+id/r_Button_Small" | |
android:layout_width="95dp" | |
android:layout_height="35dp" | |
android:layout_marginLeft="50dp" | |
android:layout_weight="1" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.322" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" /> | |
<!-- android:background="@drawable/background_selector"--> | |
<!-- android:text="@string/Medium"--> | |
<!-- android:textColor="@drawable/text_selector"--> | |
<RadioButton | |
android:id="@+id/r_Button_Medium" | |
android:layout_width="95dp" | |
android:layout_height="35dp" | |
android:layout_marginLeft="10dp" | |
android:layout_weight="1" | |
android:checked="true" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.962" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" /> | |
<!-- android:background="@drawable/background_selector"--> | |
<!-- android:text="@string/Large"--> | |
<!-- android:textColor="@drawable/text_selector"--> | |
<RadioButton | |
android:id="@+id/r_Button_Large" | |
android:layout_width="95dp" | |
android:layout_height="35dp" | |
android:layout_marginLeft="10dp" | |
android:layout_weight="1" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.962" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" /> | |
</RadioGroup> | |
<!-- android:background="@color/md_teal_800" | |
android:entries="@array/days_of_week" --> | |
<!-- //user8608556 Both spinner1 & 2 layout_width make 0dp to set in constraint added marginStart & end, change as per need --> | |
<Spinner | |
android:id="@+id/spinner1" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginStart="50dp" | |
android:layout_marginEnd="50dp" | |
android:popupBackground="#5fe0f5" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.59" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.645" | |
android:entries="@array/days_of_week"/> | |
<!-- android:background="@color/md_teal_800" | |
android:entries="@array/days_of_week_options"--> | |
<!-- //user8608556 //spinner2 start & end align to spinner1 so just margin on spinner1 will do the trick--> | |
<androidx.appcompat.widget.AppCompatSpinner | |
android:id="@+id/spinner2" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:popupBackground="#5fe0f5" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.59" | |
app:layout_constraintStart_toStartOf="parent" | |
android:layout_marginStart="50dp" | |
android:layout_marginEnd="50dp" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.723" | |
android:entries="@array/days_of_week_options"/> | |
<!-- android:text="TextViewC"--> | |
<TextView | |
android:id="@+id/textViewC" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:textColor="#000000" | |
android:textSize="20sp" | |
android:textStyle="bold" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.025" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.72" /> | |
</androidx.constraintlayout.widget.ConstraintLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can align spinner2 to parent instead of spinner1, it just you have to repeat the margins. Moreover in future you change alignment of spinner1 you need to do so on spinner2 with this approach(As you wanted both aligned below another). It sort of small code maintainability :)