Fragment with scrollview
Hi guys. Here is my current design. Linear layout with scroll view on left side with buttons keeps on expanding depending how many buttons i put. What i'm trying to do is it keep it fix size and let the scroll view do it work. I keep on changing the minWidth and minHeigth and even the layout_width and layout_height in fix size but it still keeps on expanding. Any idea what im doing wrong?.Thanks
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="800dp"
android:minHeight="600dp"
android:weightSum="100">
<!--Top Title Bar-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:weightSum="100"
android:background="#drawable/AppBarBackground">
<TextView
android:id="#+id/tvCompanyName"
android:fontFamily="#string/fontFamily"
android:text="Reports"
android:textColor="#color/white"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="15"
android:gravity="center|left"
android:textSize="#dimen/textSizeSmall"
android:textStyle="bold"
android:paddingLeft="20dp"
android:paddingRight="10dp" />
</LinearLayout>
<!--Content Layout-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="85"
android:weightSum="100">
<!--Buttons Left Size-->
<ScrollView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="30"
android:fillViewport="false">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#drawable/BackgroundWhite">
<Button
android:id="#+id/btnXReadRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="X-Read"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
<Button
android:id="#+id/btnZReadRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="Z-Read"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
<Button
android:id="#+id/btnSalesRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="Sales"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
<Button
android:id="#+id/btnDiscountRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="Discount"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
<Button
android:id="#+id/btnItemVoidRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="Item Void"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
<Button
android:id="#+id/btnTransVoidRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="Transaction Void"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
<Button
android:id="#+id/btnZReadRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="Z-Read"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
<Button
android:id="#+id/btnSalesRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="Sales"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
<Button
android:id="#+id/btnDiscountRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="Discount"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
<Button
android:id="#+id/btnItemVoidRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="Item Void"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
<Button
android:id="#+id/btnTransVoidRpt"
android:textAllCaps="false"
android:fontFamily="#string/fontFamily"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/ButtonSelectorBorderBaseColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#color/blue"
android:text="Transaction Void"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="5" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="70"
android:weightSum="100"
android:background="#drawable/BackgroundWhite" />
</LinearLayout>
</LinearLayout>
What i'm trying to do is it keep it fix size and let the scroll view do it work.
Try to set a fixed size to ScrollView instead of using match_parent.
For example:
<ScrollView
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_weight="30"
android:fillViewport="false">
...
</ScrollView>
And the result is:
If you want your layout to be fixed sized You need to set your height width fixed
i.e.
android:layout_width="YOUR WIDTH"
android:layout_height="YOUR_HEIGHT"
Related
Hi,
I am trying to create Cancel button on top of the view like in above image.while scroll also image should be still. i have used Floating button.Cancel image is coming as normal but floating round background still coming in the background.i want to remove it.how to remove it or any other way to do it.
Here is my code :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
tools:context=".activities.ProductDetailsSingleActivity">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/cancel_image"
android:layout_alignParentTop="true"
style="?android:attr/borderlessButtonStyle"
android:background="#android:color/transparent"
app:rippleColor="#null"
app:backgroundTint="#null"
android:src="#drawable/cancel1" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/cancel_image">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/imageView1"
android:layout_margin="10dp"
android:layout_width="300dp"
android:layout_height="200dp"
android:src="#drawable/con_pump5"
android:layout_centerHorizontal="true"
/>
<LinearLayout
android:id="#+id/ll_album_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_below="#id/imageView1"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="8dp"
android:paddingTop="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/ll_media_count"
android:orientation="horizontal">
<TextView
android:id="#+id/rupees"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="4dp"
android:paddingRight="4dp"
android:maxLines="1"
android:text="Rs.12,00,000"
android:textColor="#color/colorBlack"
android:textSize="14sp" />
<ImageView
android:id="#+id/album_media_label"
android:layout_width="20dp"
android:text="media"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="#drawable/outline_favorite_border_black_18" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/decription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="Silos for selling with good condi.."
android:textColor="#color/colorBlack"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/location2"/>
<TextView
android:id="#+id/location"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:maxLines="1"
android:ellipsize="end"
android:text="Bangalore,Karnataka"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:id="#+id/view_line"
android:layout_width="match_parent"
android:layout_below="#+id/ll_album_info"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/des_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_below="#+id/view_line"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description :"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#android:color/black"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/des"
android:textSize="15sp"
android:textColor="#color/colorBlack"
/>
</LinearLayout>
<View
android:id="#+id/view_line2"
android:layout_width="match_parent"
android:layout_below="#+id/des_linear"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/detail_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_below="#+id/view_line2"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Details :"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#android:color/black"/>
</LinearLayout>
<LinearLayout
android:id="#+id/last_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_below="#+id/detail_linear"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="#+id/text_FeeType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="#string/company_name"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:id="#+id/text_name_Val"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/company_name1"
android:textSize="15sp"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="#+id/text_FeeAmount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="#string/contact_person"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:id="#+id/text_class_Val"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/contact_person1"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:visibility="visible"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="#+id/text_reg_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="#string/mobile_no"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:id="#+id/text_reg_Val"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/mobile_no1"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="#+id/text_class_teacher"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:text="#string/landline_no"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:id="#+id/text_class_teacher_Val"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/landline_no"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="#+id/text_birth_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="#string/address"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:id="#+id/text_birth_date_Val"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/address1"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="#+id/text_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="#string/location"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:id="#+id/text_address_Val"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/location1"
android:textColor="#color/colorBlack"
android:textSize="15sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="#string/model_of_year"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/model_of_year1"
android:textSize="15sp"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="#string/serial_number"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/serial_number1"
android:textSize="15sp"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="#string/new_machine_cost"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/new_machine_cost1"
android:textSize="15sp"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="#string/expecting_cost"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/expecting_cost1"
android:textSize="15sp"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:text="#string/comments"
android:textSize="15sp"
android:textColor="#color/colorBlack"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="#string/comments1"
android:textSize="15sp"
android:textColor="#color/colorBlack" />
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:textColor="#color/colorBlack"
android:layout_below="#+id/last_linear"
android:text="CHAT"/>
</RelativeLayout>
</ScrollView>
Do like this way: First, add the Scroll view in the parent layout with attribute align parent top as true. Then below Scrollview, you can add the cancel button also have attribute align parent top as true.
I need to align the images and buttons equall with the header but it's not assigning. When I check in landscape, align getting mismatch. Here is my code.
When I checked in device, it's not fitting correctly.
Below is the code and output screen (My output and actual output which needed).
I used weight but it's not fitting correctly in all devices.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="29dp"
android:layout_marginTop="16dp"
android:background="#color/colorAlabaster">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="50dp"
android:gravity="center"
android:text="Retailer" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="Hari sebelumnya" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:text="Pindahkan ke hari" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_weight="1">
<com.hutchison.h3i.newangie.customviews.CircleImageView
android:id="#+id/recycle_profile"
android:layout_width="#dimen/growth_sell_in_out_icon_size"
android:layout_height="#dimen/growth_sell_in_out_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:src="#drawable/ic_default_profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:orientation="vertical">
<TextView
android:id="#+id/recycle_txt_acc_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_number"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_very_small" />
<TextView
android:id="#+id/recycle_txt_acc_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_name"
android:textColor="#color/colorCyan"
android:textSize="#dimen/text_size_very_small" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="86dp"
android:layout_height="29dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_marginLeft="8dp"
android:background="#drawable/border_grey_curve"
android:text="Selasa"
android:textAllCaps="false"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".2">
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#drawable/ic_arrow_right"
android:gravity="center"
android:textColor="#color/colorBlack"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="86dp"
android:layout_height="29dp"
android:background="#drawable/border_grey_curve"
android:drawablePadding="5dp"
android:drawableRight="#drawable/ic_arrow_bottom"
android:singleLine="true"
android:text="Kamis"
android:textAllCaps="false"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_small" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
My Output:
Actual output:
Here i have fixed the issue for you. But as the screen size will increase so does the size between your button and upper portion too. But your layout won't get messy. And if you want everything to remain fixed even on bigger screen sizes then you should use constraintLayout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="29dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryLight">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="50dp"
android:gravity="center"
android:text="Retailer" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="Hari sebelumnya" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:text="Pindahkan ke hari" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:weightSum="4">
<com.hutchison.h3i.newangie.customviews.CircleImageView
android:id="#+id/recycle_profile"
android:layout_width="#dimen/growth_sell_in_out_icon_size"
android:layout_height="#dimen/growth_sell_in_out_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:src="#drawable/ic_default_profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_weight="0.5"
android:orientation="vertical">
<TextView
android:id="#+id/recycle_txt_acc_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="sad234 234234"
android:textColor="#color/primary_text"
android:textSize="12sp" />
<TextView
android:id="#+id/recycle_txt_acc_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/title_activity_test"
android:textColor="#color/secondary_text"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1.5">
<android.support.v7.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="8dp"
android:background="#drawable/bg_spinner_nothing_selected"
android:gravity="center"
android:text="Selasa"
android:textAllCaps="false"
android:textColor="#color/primary_text" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight=".5">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#drawable/ic_add"
android:gravity="center"
android:textColor="#color/primary_text"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1.5">
<android.support.v7.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#drawable/bg_spinner_nothing_selected"
android:drawableRight="#drawable/ic_edit_grey"
android:singleLine="true"
android:text="Kamis"
android:textAllCaps="false"
android:textColor="#color/primary_text"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Hope it will help you. I have replaced the colors and ic_images with mine you will have to change them too by your own.
Hope this would work. I redesign with your same xml file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="29dp"
android:layout_marginTop="16dp"
android:background="#color/colorAlabaster">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Retailer" />
<TextView
android:id="#+id/textView9"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Hari sebelumnya" />
<TextView
android:layout_width="0dp"
android:layout_weight=".2"
android:layout_height="wrap_content"
android:gravity="center" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Pindahkan ke hari" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginLeft="8dp"
android:layout_weight="1">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<com.hutchison.h3i.newangie.customviews.CircleImageViewx
android:id="#+id/recycle_profile"
android:layout_width="#dimen/growth_sell_in_out_icon_size"
android:layout_height="#dimen/growth_sell_in_out_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:src="#drawable/ic_default_profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/recycle_txt_acc_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_number"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_very_small" />
<TextView
android:id="#+id/recycle_txt_acc_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_name"
android:textColor="#color/colorCyan"
android:textSize="#dimen/text_size_very_small" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#drawable/border_grey_curve"
android:text="Selasa"
android:textAllCaps="false"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_weight=".2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center">
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:background="#drawable/ic_arrow_right"
android:gravity="center"
android:textColor="#color/colorBlack"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="86dp"
android:layout_height="29dp"
android:background="#drawable/border_grey_curve"
android:drawablePadding="5dp"
android:drawableRight="#drawable/ic_arrow_bottom"
android:singleLine="true"
android:text="Kamis"
android:textAllCaps="false"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_small" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I'm new to Android dev so sorry for what is probably a basic question....
I'm trying to get 2 textviews to appear at the top of the screen and take up an equal amount of space each BUT to have a margin of say 20dp between the 2 views and on the left and the right hand side of the screen.
Much like
My code currently is:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A1887F"
android:orientation="horizontal">
<TextView
android:id ="#+id/1_Heading"
android:text="1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:background="#4CAF50"
android:padding="10dp"
android:textColor="#ffffff"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" />
<TextView
android:id ="#+id/2_Heading"
android:text="2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:background="#4CAF50"
android:padding="10dp"
android:textColor="#ffffff"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
</LinearLayout>
Any ideas and sorry if this is a basic question - I've tried to find a solution online but nothing much helps.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A1887F"
android:weightSum="2"
android:orientation="horizontal">
<TextView
android:id ="#+id/1_Heading"
android:text="1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:background="#4CAF50"
android:padding="10dp"
android:textColor="#ffffff"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
<TextView
android:id ="#+id/2_Heading"
android:text="2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:background="#4CAF50"
android:padding="10dp"
android:textColor="#ffffff"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
</LinearLayout>
You just need to give half right margin to your first Textview and half left margin to your second Textview as below:-
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A1887F"
android:orientation="horizontal">
<TextView
android:id ="#+id/1_Heading"
android:text="1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:background="#4CAF50"
android:padding="10dp"
android:textColor="#ffffff"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp" />
<TextView
android:id ="#+id/2_Heading"
android:text="2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:background="#4CAF50"
android:padding="10dp"
android:textColor="#ffffff"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
</LinearLayout>
you can handle this with giving a 20dp padding to parent (LinearLayout) and then 10dp margin from end to the first button, and 10dp margint from start to the second button.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A1887F"
android:padding="20dp"
android:orientation="horizontal">
<TextView
android:text="1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:background="#4CAF50"
android:padding="10dp"
android:textColor="#ffffff"
android:layout_marginEnd="10dp"
/>
<TextView
android:text="2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:background="#4CAF50"
android:padding="10dp"
android:textColor="#ffffff"
android:layout_marginStart="10dp"
/>
Try with this layout xml.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A1887F"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:id="#+id/heading1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="#4CAF50"
android:padding="5dp"
android:text="1"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ffffff" />
<TextView
android:id="#+id/heading2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="#4CAF50"
android:padding="5dp"
android:text="2"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ffffff" />
</LinearLayout>
Try this one :
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A1887F"
android:layout_weight="100"
android:orientation="horizontal">
<TextView
android:id ="#+id/Heading_1"
android:text="1"
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:background="#4CAF50"
android:padding="10dp"
android:textColor="#ffffff"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
<TextView
android:id ="#+id/Heading_2"
android:text="2"
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:background="#4CAF50"
android:padding="10dp"
android:textColor="#ffffff"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
</LinearLayout>
Results :
Give android:layout_marginEnd="10dp"on the First TextView
Give android:layout_marginStart="10dp"on the Second TextView
Was Able to achieve this using below code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A1887F"
android:orientation="horizontal">
<TextView
android:id="#+id/btn1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:padding="10dp"
android:background="#4CAF50"
android:text="1"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ffffff" />
<TextView
android:id="#+id/btn2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:padding="10dp"
android:background="#4CAF50"
android:text="2"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ffffff" />
</LinearLayout>
This question already has answers here:
How do you make a LinearLayout scrollable?
(10 answers)
Closed 3 months ago.
I am having a popup view in an android app. For the portrait screen the popup page showing properly, but if i rotate the screen to landscape the popup layout display partially. I have click buttons in the popup. Can't view the buttons in landscape mode. The popup page i am using is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/popup_element"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#333333"
android:gravity="center"
android:orientation="vertical"
tools:ignore="ButtonStyle" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose_emotion"
android:textColor="#color/white"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_sad"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/sky_ring"
android:text="#string/emo_sad"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_happy"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/yellow_ring"
android:text="#string/emo_happy"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_depressed"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/blue_ring"
android:text="#string/emo_depressed"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_question"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_margin="8dp"
android:background="#drawable/gray_ring_question"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_anxious"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/orange_ring"
android:text="#string/emo_anxious"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_neutral"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/white_ring"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/emo_neutral"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_angry"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/red_ring"
android:text="#string/emo_angry"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_done_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/done_btn"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_close_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:text="#string/cancel_btn"
android:textColor="#color/white" />
</LinearLayout>
</LinearLayout>
How can i display the full page in the screen in landscape or for small screens? Any help would be appreciated. Thanks in advance.
Check This I used your xml(change your background):-
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/popup_element"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#333333"
android:gravity="center"
android:orientation="vertical"
tools:ignore="ButtonStyle" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="choose_emotion"
android:textColor="#color/white"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_sad"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/ic_launcher"
android:text="emo_sad"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_happy"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_happy"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_depressed"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_depressed"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_question"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_margin="8dp"
android:background="#drawable/ic_launcher"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_anxious"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_anxious"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_neutral"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/ic_launcher"
android:text="emo_neutral"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_angry"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/ic_launcher"
android:text="emo_angry"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_done_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="done_btn"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_close_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:text="cancel_btn"
android:textColor="#color/white" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Try this as you know ScrollView can have only one child so you put the ScrollView as parent Layout and then One child will be the linearlayout and then that will work. Try like this:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:id="#+id/popup_element"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#333333"
android:gravity="center"
android:orientation="vertical"
tools:ignore="ButtonStyle" >
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose_emotion"
android:textColor="#color/white"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_sad"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/sky_ring"
android:text="#string/emo_sad"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_happy"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/yellow_ring"
android:text="#string/emo_happy"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_depressed"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/blue_ring"
android:text="#string/emo_depressed"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_question"
android:layout_width="83dp"
android:layout_height="83dp"
android:layout_margin="8dp"
android:background="#drawable/gray_ring_question"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_anxious"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/orange_ring"
android:text="#string/emo_anxious"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/emo_neutral"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/white_ring"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/emo_neutral"
android:textColor="#color/white"
android:textSize="12sp" />
<Button
android:id="#+id/emo_angry"
android:layout_width="83dp"
android:layout_height="83dp"
android:background="#drawable/red_ring"
android:text="#string/emo_angry"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_done_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:text="#string/done_btn"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_close_popup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:text="#string/cancel_btn"
android:textColor="#color/white" />
</LinearLayout>
But it is better that you use RelativeLayout instead of using so many linearlayouts. Hope it helps.
A ScrollView is a FrameLayout, meaning you must place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects.
So you have to solve your problem with concept clearing you can follow my answer of this question. may it will clear your concept and help to solve your problem.
you can only take single tag(Child Layout) in scrollview. if you have put multiple Linear Layout then take single linearlayout and then put other Linear Layout in this.
I am keeping 9 images in a 3 rows like a 3X3 matrix. I am getting error while we are providing layout_weightsum so i changed it to weightsum. still it is showing me error. I am using Andorid Studio.
Below is my code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/third_screen">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/scroll_screen3"
android:layout_alignParentTop="true"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/retreat_2"
android:id="#+id/screen3_view">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="CHOOSE YOUR RETREAT"
android:id="#+id/txt_welcome"
android:focusableInTouchMode="false"
android:layout_gravity="center_horizontal"
android:textSize="20sp"
android:textColor="#ffffffff"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:gravity="center_horizontal" />
<ImageView
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/hover"
android:src="#drawable/hover"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp" />
<LinearLayout
android:background="#drawable/outline1"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="418dp"
android:layout_margin="20dp"
android:weightsum="3"
android:id="#+id/outline_pockets" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="#+id/first_line_pockets"
android:layout_weightsum="3"
android:layout_weight="1"
android:layout_marginTop="10dp">
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="#+id/pocket11"
android:src="#drawable/img1"
android:layout_weight="1" />
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="#+id/pocket12"
android:src="#drawable/img2"
android:layout_weight="1" />
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="#+id/pocket13"
android:src="#drawable/img3"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/first_line_txt"
android:layout_gravity="center_vertical"
android:weightsum="3" >
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="UNREASONABLE JOY"
android:layout_gravity="center_horizontal"
android:lines="2"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:gravity="center_vertical|center_horizontal"
android:textSize="13sp"
android:layout_weight="1"
android:id="#+id/txt_pocket11" />
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="LIGHTEN UP"
android:layout_gravity="center_horizontal"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:gravity="center_vertical|center_horizontal"
android:textSize="13sp"
android:layout_weight="1"
android:id="#+id/txt_pocket12" />
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="RELEASING DISEASE"
android:id="#+id/txt_pocket13"
android:lines="2"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal"
android:gravity="center_vertical|center_horizontal"
android:textSize="13sp"
android:textIsSelectable="false"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/second_line_pockets"
android:weightsum="3"
android:layout_weight="1">
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="#+id/pocket21"
android:src="#drawable/img4"
android:layout_weight="1" />
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="#+id/pocket22"
android:src="#drawable/img5"
android:layout_weight="1" />
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="#+id/pocket23"
android:src="#drawable/img6"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:id="#+id/second_line_txt"
android:weightsum="3" >
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="BEYOND FEVER"
android:autoText="false"
android:lines="2"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="13sp"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
android:id="#+id/txt_pocket21" />
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="UNSHAKEABLE LOVE"
android:layout_gravity="center_horizontal"
android:lines="2"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="13sp"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
android:id="#+id/txt_pocket22" />
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="PEACEFUL PARENTING"
android:textSize="13sp"
android:lines="2"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:layout_gravity="center_horizontal"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
android:id="#+id/txt_pocket23" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/third_line_pockets"
android:weightsum="3"
android:layout_weight="1">
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="#+id/pocket31"
android:src="#drawable/img7"
android:layout_weight="1" />
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="#+id/pocket32"
android:src="#drawable/img8"
android:layout_weight="1" />
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="#+id/pocket33"
android:src="#drawable/img9"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/third_line_txt"
android:weightsum="3"
android:layout_marginBottom="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="GETTING UNSTUCK"
android:autoText="false"
android:layout_gravity="center_vertical"
android:lines="2"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:gravity="center_vertical|center_horizontal"
android:textIsSelectable="false"
android:textSize="13sp"
android:layout_weight="1"
android:id="#+id/txt_pocket31" />
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="WARRIOR MONK"
android:lines="2"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:layout_gravity="center_vertical"
android:gravity="center_vertical|center_horizontal"
android:textSize="13sp"
android:layout_weight="1"
android:id="#+id/txt_pocket32" />
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="FILLING YOUR CUP"
android:lines="2"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:layout_gravity="center_vertical"
android:gravity="center_vertical|center_horizontal"
android:textSize="13sp"
android:singleLine="false"
android:layout_weight="1"
android:id="#+id/txt_pocket33" />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="80dp"
android:id="#+id/no_more"
android:src="#drawable/no_more"
android:layout_marginTop="10dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/retreat_quiz"
android:src="#drawable/retreat_quiz"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
The correct spelling for the attribute is weightSum, not weightsum or layout_weightsum.
However, the system can calculate the sum for you. You can just omit the attribute altogether.