What is the difference between layout_alignEnd and layout_alignRight?

VanechikSpace

My layout:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="8dp">

    <TextView
        android:id="@+id/crime_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Crime Title" />

    <TextView
        android:id="@+id/crime_date"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/crime_title"
        android:text="Crime Date" />

    <Button
        android:id="@+id/crime_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@id/crime_title" />

</RelativeLayout>

Output:

enter image description here

If i replace android:layout_alignRight="@id/crime_title" with android:layout_alignEnd="@id/crime_title", i get the following output:

enter image description here

The documentation says about alignEnd :Makes the end edge of this view match the end edge of the given anchor view ID, whereas about alignRight: Makes the right edge of this view match the right edge of the given anchor view ID

Question: Isn't "a right edge" the same as "an end edge" ? And what does that blue circle, that has appeared, mean ? What is the difference between these two attributes ?

memres

When using android:layout_alignRight you get a compiler warning saying

Consider replacing android:layout_alignRight with android:layout_alignEnd="@id/crime_title" to better support right-to-left layouts

If you dont use any right-to-left layouts you won't see any difference between android:layout_alignRight and android:layout_alignEnd. They behave same.

You can see the difference in preview while editing your layout file by enabling "Preview Right to Left". When using android:layout_alignRight your button will stay always on the right even in right to left layouts:

enter image description here

When using android:layout_alignEnd your button will be automatically positioned to ensure matching the end edge of the given anchor view ID. This is also what that blue circle means:

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What is the difference between parsys component and responsive layout in AEM

What is difference between Barrier and Guideline in Constraint Layout?

What is the difference between background, backgroundTint, backgroundTintMode attributes in android layout xml?

What's the difference between "as?", "as!", and "as"?

What is the difference between gravity and layout_gravity in Android?

What is the difference between all these Auto Layout update methods? Are all necessary?

What is the difference between Partial View and Layout?

ViewStart and Layout - what's the difference?

What is the basic difference between Auto Layout and Auto Resizing in iOS

What's the difference between the layout_alignStart tag and layout_alignLeft?

When to use translate and when relocate - What is the difference between translate and layout coordinates?

What is the difference between align-items vs. align-content in Grid Layout?

What is the difference between :: and . in Rust?

When should you use layout="fill" versus layout="responsive" on amp-video in amp-story? What is the difference between the two?

What's the difference between Box layout model and Sliver layout model (BoxConstraints and SliverConstraints) in Flutter?

In SwiftUI, what's the difference between .modifier and .layout

What is the difference between *++a and ++*b?

What is the conceptual difference between a Plotly Dash layout and a component?

What's the difference (in FXML) between layout.Pane and control.Control?

What is the difference between layout-sw801dp and layout-v21?

What is the difference between && and ||?

Difference between Layout and Fragment Layout

What's the difference between layout_gravity="center_vertical" and layout_centerVertical="true"

What is the difference between "normal" and "latin-9 only" keyboard layout?

What is the difference between android:layout_alignRight="ID" and android:layout_toRightOf="ID"?

Difference between layout:column and layout:columnSpan

what the difference between layout and viewGroup in android

Difference between Tab Layout and ViewPager?

What is the difference between Normal Flow, Flow Layout, Block and Inline Layout?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive