0

I have a problem with layout in my app that I am writing. I want to make some domestic changes like buttons to be in one column and they should be on right hand side. Additionally EditText with Buttons should be around middle of the screen ( I attach screenshot of how it looks for now). After reading few of similar problems the main idea was to modify textView1 on layout_width="fill_parent", but that doesnt make any difference. Most of changes that I am trying doesnt seems to have any effect, do you know why ?Current Layout

I am also giving the adapter view layout xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="100">


    <TextView
        android:gravity="center"
        android:text="TextView1"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:id="@+id/textView1"
        android:textSize="18sp"
        android:layout_weight="66.6"/>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_weight="33.3">

        <Button
            android:id="@+id/removeBtn"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:background="@drawable/custom_btn_remove"
            android:backgroundTint="@color/black" />


        <EditText
            android:id="@+id/itemAmount"
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:gravity="center_horizontal"
            android:inputType="number"
            android:minEms="1"
            android:text="1"
            android:textAlignment="center"
            android:textAllCaps="false"
            android:textColor="@android:color/black"
            android:textSize="20sp" />

        <Button
            android:id="@+id/addBtn"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:background="@drawable/custom_btn_add"
            android:backgroundTint="@color/black" />

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/floatingActionButton"
            android:layout_marginLeft="60dp"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_alignParentRight="true"
            android:layout_weight="1"
            android:clickable="true"
            app:fabCustomSize="40dp"
            app:srcCompat="?android:attr/textCheckMarkInverse" />

    </LinearLayout>


</LinearLayout>
  • Weight doesn't have any effect if the width is not `0dp`. Change widths to the views with weights to `0dp` to see how that works for you. Edit your question if these changes comes close but is not quite what you need. – Cheticamp Oct 19 '21 at 01:38
  • So your advice did the trick about moving parts, so thanks. Despite that I am still not able to place buttons in one column and additionally parts of them starts to disappear – michał Zwierzyński Oct 20 '21 at 10:08
  • If you need the widgets to line up in strict columns and rows, consider using either _ConstraintLayout_ (preferred), _GridLayout_ or _TableLayout_. Maybe [this Stack Oerflow post](https://stackoverflow.com/questions/42846261/trying-to-replicate-gridlayout-column-alignment-with-constraintlayout) can help. – Cheticamp Oct 20 '21 at 11:27

0 Answers0