• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Is this the most practical layout.

carelv7

Newbie
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:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:eek:rientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:eek:rientation="vertical"
tools:context="com.example.android.justjava.MainActivity">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingTop="8dp">

<ImageView
android:id="@+id/beer_logo"
android:layout_width="68dp"
android:layout_height="58dp"
android:src="@drawable/black_label" />
<TextView
android:id="@+id/text_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="(85023) Black Label 340ml NRB"
android:textAlignment="textStart"
android:layout_toRightOf="@id/beer_logo"/>
<TextView
android:id="@+id/TotalCases"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="24sp"
android:layout_gravity="center_horizontal"
android:layout_below="@id/text_name"
android:layout_centerHorizontal="true" />

</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:eek:rientation="horizontal"
android:gravity="center_horizontal">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:eek:rientation="horizontal">
<Button
android:id="@+id/casePlus1"
android:layout_width="68dp"
android:layout_height="58dp"
android:eek:nClick="casesPlusOne"
android:text="Cases\n+1"
android:textAllCaps="false"/>
<Button
android:id="@+id/caseMinus1"
android:layout_width="68dp"
android:layout_height="58dp"
android:eek:nClick="casesMinusOne"
android:text="Cases\n-1"
android:textAllCaps="false"/>
</LinearLayout>

<TextView
android:id="@+id/cases_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:text="0"
android:textColor="@android:color/black"
android:textSize="16sp" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:eek:rientation="horizontal">
<Button
android:id="@+id/caseMinus10"
android:layout_width="68dp"
android:layout_height="58dp"
android:eek:nClick="casesMinusTen"
android:text="Cases\n-10"
android:textAllCaps="false"/>
<Button
android:id="@+id/casePlus10"
android:layout_width="68dp"
android:layout_height="58dp"
android:eek:nClick="casesPlusTen"
android:text="Cases\n+10"
android:textAllCaps="false"/>
</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:eek:rientation="horizontal"
android:gravity="center">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:eek:rientation="horizontal">
<Button
android:id="@+id/palletsPlus1"
android:layout_width="68dp"
android:layout_height="58dp"
android:eek:nClick="palletsPlusOne"
android:text="Pallets\n+1"
android:textAllCaps="false"/>
<Button
android:id="@+id/palletsMinus1"
android:layout_width="68dp"
android:layout_height="58dp"
android:eek:nClick="palletsMinusOne"
android:text="Pallets\n-1"
android:textAllCaps="false"/>
</LinearLayout>

<TextView
android:id="@+id/pallets_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="0"
android:textColor="@android:color/black"
android:textSize="16sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:eek:rientation="horizontal">
<Button
android:id="@+id/palletsMinusTen"
android:layout_width="68dp"
android:layout_height="58dp"
android:eek:nClick="palletsMinusTen"
android:text="Pallest\n-10"
android:textAllCaps="false"/>
<Button
android:id="@+id/palletsPlus10"
android:layout_width="68dp"
android:layout_height="58dp"
android:eek:nClick="palletsPlusTen"
android:text="Pallets\n+10"
android:textAllCaps="false"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
 
Last edited by a moderator:
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.
 
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.
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?
 

Attachments

  • Screenshot_20170704-232136.jpg
    Screenshot_20170704-232136.jpg
    63.3 KB · Views: 139
You might want to look into using a CardView for this.
 
T
You might want to look into using a CardView for this.
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.
 
Back
Top Bottom