1. Are you ready for the Galaxy S20? Here is everything we know so far!

Is this the most practical layout.

Discussion in 'Android Development' started by carelv7, Jul 4, 2017.

  1. carelv7

    carelv7 Newbie
    Thread Starter

    Hi, hope you are all well
    With all the different ways of layout, relative and linear to name a few, is this the most practical and efficient way I could have achieved this. Talking about loading and using up resources and so. I want to use it in a array adapter.

    Here is my code:

    Code (Text):
    1.  
    2. <LinearLayout
    3. xmlns:android="http://schemas.android.com/apk/res/android"
    4. xmlns:tools="http://schemas.android.com/tools"
    5. android:layout_width="match_parent"
    6. android:layout_height="wrap_content"
    7. android:eek:rientation="vertical">
    8.  
    9. <LinearLayout
    10. android:layout_width="match_parent"
    11. android:layout_height="match_parent"
    12. android:eek:rientation="vertical"
    13. tools:context="com.example.android.justjava.MainActivity">
    14.  
    15. <RelativeLayout
    16. android:layout_width="match_parent"
    17. android:layout_height="match_parent"
    18. android:paddingLeft="8dp"
    19. android:paddingTop="8dp">
    20.  
    21. <ImageView
    22. android:id="@+id/beer_logo"
    23. android:layout_width="68dp"
    24. android:layout_height="58dp"
    25. android:src="@drawable/black_label" />
    26. <TextView
    27. android:id="@+id/text_name"
    28. android:layout_width="wrap_content"
    29. android:layout_height="wrap_content"
    30. android:textSize="20sp"
    31. android:text="(85023) Black Label 340ml NRB"
    32. android:textAlignment="textStart"
    33. android:layout_toRightOf="@id/beer_logo"/>
    34. <TextView
    35. android:id="@+id/TotalCases"
    36. android:layout_width="wrap_content"
    37. android:layout_height="wrap_content"
    38. android:text="0"
    39. android:textSize="24sp"
    40. android:layout_gravity="center_horizontal"
    41. android:layout_below="@id/text_name"
    42. android:layout_centerHorizontal="true" />
    43.  
    44. </RelativeLayout>
    45. <LinearLayout
    46. android:layout_width="match_parent"
    47. android:layout_height="match_parent"
    48. android:eek:rientation="horizontal"
    49. android:gravity="center_horizontal">
    50.  
    51. <LinearLayout
    52. android:layout_width="wrap_content"
    53. android:layout_height="wrap_content"
    54. android:eek:rientation="horizontal">
    55. <Button
    56. android:id="@+id/casePlus1"
    57. android:layout_width="68dp"
    58. android:layout_height="58dp"
    59. android:eek:nClick="casesPlusOne"
    60. android:text="Cases\n+1"
    61. android:textAllCaps="false"/>
    62. <Button
    63. android:id="@+id/caseMinus1"
    64. android:layout_width="68dp"
    65. android:layout_height="58dp"
    66. android:eek:nClick="casesMinusOne"
    67. android:text="Cases\n-1"
    68. android:textAllCaps="false"/>
    69. </LinearLayout>
    70.  
    71. <TextView
    72. android:id="@+id/cases_text_view"
    73. android:layout_width="wrap_content"
    74. android:layout_height="wrap_content"
    75. android:paddingTop="16dp"
    76. android:paddingRight="16dp"
    77. android:paddingLeft="16dp"
    78. android:text="0"
    79. android:textColor="@android:color/black"
    80. android:textSize="16sp" />
    81.  
    82. <LinearLayout
    83. android:layout_width="wrap_content"
    84. android:layout_height="wrap_content"
    85. android:eek:rientation="horizontal">
    86. <Button
    87. android:id="@+id/caseMinus10"
    88. android:layout_width="68dp"
    89. android:layout_height="58dp"
    90. android:eek:nClick="casesMinusTen"
    91. android:text="Cases\n-10"
    92. android:textAllCaps="false"/>
    93. <Button
    94. android:id="@+id/casePlus10"
    95. android:layout_width="68dp"
    96. android:layout_height="58dp"
    97. android:eek:nClick="casesPlusTen"
    98. android:text="Cases\n+10"
    99. android:textAllCaps="false"/>
    100. </LinearLayout>
    101.  
    102. </LinearLayout>
    103.  
    104. <LinearLayout
    105. android:layout_width="match_parent"
    106. android:layout_height="match_parent"
    107. android:eek:rientation="horizontal"
    108. android:gravity="center">
    109.  
    110. <LinearLayout
    111. android:layout_width="wrap_content"
    112. android:layout_height="wrap_content"
    113. android:eek:rientation="horizontal">
    114. <Button
    115. android:id="@+id/palletsPlus1"
    116. android:layout_width="68dp"
    117. android:layout_height="58dp"
    118. android:eek:nClick="palletsPlusOne"
    119. android:text="Pallets\n+1"
    120. android:textAllCaps="false"/>
    121. <Button
    122. android:id="@+id/palletsMinus1"
    123. android:layout_width="68dp"
    124. android:layout_height="58dp"
    125. android:eek:nClick="palletsMinusOne"
    126. android:text="Pallets\n-1"
    127. android:textAllCaps="false"/>
    128. </LinearLayout>
    129.  
    130. <TextView
    131. android:id="@+id/pallets_text_view"
    132. android:layout_width="wrap_content"
    133. android:layout_height="wrap_content"
    134. android:paddingLeft="16dp"
    135. android:paddingRight="16dp"
    136. android:text="0"
    137. android:textColor="@android:color/black"
    138. android:textSize="16sp" />
    139. <LinearLayout
    140. android:layout_width="wrap_content"
    141. android:layout_height="wrap_content"
    142. android:eek:rientation="horizontal">
    143. <Button
    144. android:id="@+id/palletsMinusTen"
    145. android:layout_width="68dp"
    146. android:layout_height="58dp"
    147. android:eek:nClick="palletsMinusTen"
    148. android:text="Pallest\n-10"
    149. android:textAllCaps="false"/>
    150. <Button
    151. android:id="@+id/palletsPlus10"
    152. android:layout_width="68dp"
    153. android:layout_height="58dp"
    154. android:eek:nClick="palletsPlusTen"
    155. android:text="Pallets\n+10"
    156. android:textAllCaps="false"/>
    157. </LinearLayout>
    158. </LinearLayout>
    159. </LinearLayout>
    160. </LinearLayout>
    161.  
     


    #1 carelv7, Jul 4, 2017
    Last edited by a moderator: Jul 4, 2017

    1. Download the Forums for Android™ app!


      Download

       
  2. Deleted User

    Deleted User Guest

    It's difficult to visualise your layout just from the XML. Do you have a screenshot of it?
    And what part of this are you intending to use with an ArrayAdapter? Normally this would be used in conjunction with a ListView, and the associated row layouts are normally fairly simple Views.
     
  3. carelv7

    carelv7 Newbie
    Thread Starter

    I want to make an order app which gets converted into an email and send to the call centre. So each product must have a layout like this
    This is how it looks Do you think it is to big for a ListView?
     

    Attached Files:

  4. Deleted User

    Deleted User Guest

    You might want to look into using a CardView for this.
     
  5. carelv7

    carelv7 Newbie
    Thread Starter

    T
    Thank you, I will look into that. I think also I will make it smaller, remove the +10's, and just have single cases and pallets, (the pallets anyway jump the cases with 84 already) I will post it after I'm done.
     
Loading...
Similar Threads - practical layout
  1. Lenthall
    Replies:
    5
    Views:
    550
  2. twilight_dream
    Replies:
    2
    Views:
    795
  3. HarryC
    Replies:
    5
    Views:
    756
  4. markdem
    Replies:
    0
    Views:
    587
  5. Bill_
    Replies:
    3
    Views:
    656
  6. ApeironVpn
    Replies:
    1
    Views:
    402
  7. Becca Lou
    Replies:
    0
    Views:
    983
  8. pengyou
    Replies:
    0
    Views:
    600
  9. MoodyBlues
    Replies:
    16
    Views:
    5,143
  10. Samsung
    Replies:
    0
    Views:
    759

Share This Page

Loading...