Trouble with margins for Button - android

I'm having a LinearLayout with two TextView's and a Button.
I've styled the TextView's to be a little below other parts, by using layout_marginTop. This works correctly.
However, I want to move the button down more as well, but adapting the layout_marginTop property does not seem to help. All others (like padding) do work, but only the one I need doesn't work ofcourse.
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="The value:"
android:id="#+id/HeaderTextView"
android:layout_gravity="left|top"
android:layout_marginTop="20dip"
android:fontFamily="sans-serif-light"
android:textStyle="normal|bold"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="-"
android:id="#+id/ValueTextView"
android:layout_below="#id/HeaderTextView"
android:layout_marginTop="10dip"
android:layout_gravity="left|center_vertical"
android:fontFamily="sans-serif-thin" />
<Button
android:background="#drawable/red_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Reset Alarm"
android:layout_below="#id/ValueTextView"
android:layout_marginTop="120dip"
android:id="#+id/getValueButton"
style="#style/button_text"/>
</LinearLayout>
The top of the button is currently sticked against the bottom of the TextView above it. How come I can't move the button down?

activity1.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/HeaderTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|top"
android:layout_marginTop="20dip"
android:fontFamily="sans-serif-light"
android:text="Performance informatie"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="normal|bold" />
<TextView
android:id="#+id/ValueTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="10dip"
android:text="-p789t89549"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/getValueButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Reset Alarm"
android:layout_gravity="bottom"/>
</LinearLayout>
activity2.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layout1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Commando "
android:textAppearance="?android:attr/textAppearanceLarge" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/spinneritems"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Weger"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cel"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text "
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Gewicht"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text "
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Tolerantie"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text "
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<Button
android:id="#+id/share"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text=" Uitvoeren" />
</LinearLayout>
Now this layout will include both and will act as your main layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<include layout="#layout/activity1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"/>
<include layout="#layout/activity2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"/>
</LinearLayout>

Related

Android - row of buttons at bottom disappears (not in designer)

The app has a screen that needs at the bottom a button bar. Above are a few text views and 1 editview.
When the user starts editing, the software keyboard becomes visible. I would like the buttons to move up and always be visible. The rest of the views should shrink.
Normally I would expect the below code to work. I tried many options, e.g. with a RelativeLayout as top layout manager.
==> The result is that the button bar is gone!
When I remove the Scrollview, then the buttons bar is visible again.
Why does the button bar disappear? In the designer it is visible.
My first series of attempts (that I use in other screens) uses a RelativeLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="horizontal" >
<ScrollView
android:id="#+id/layout_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_above="#id/bottom_buttons"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Notes"
android:textStyle="bold" />
<EditText
android:id="#+id/the_edit_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:hint="Notes"
android:minLines="3"
android:text="" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some static text"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some dynamic text />
</LinearLayout>
<TextView
android:id="#+id/abc_explanation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_vertical"
android:text="" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/bottom_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<Button
android:layout_alignParentBottom="true"
android:id="#+id/save_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
<Button ... 2>
<Button ... 3>
</LinearLayout>
</RelativeLayout>
In my AndroidManifest.xml I use normally:
<activity
android:name="xy.organisation.app.MainActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustResize"
android:configChanges="keyboard|keyboardHidden|orientation" >
My second series of attempts is using a LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="#+id/layout_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Notes"
android:textStyle="bold" />
<EditText
android:id="#+id/the_edit_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:hint="Notes"
android:minLines="3"
android:text="" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some static text"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some dynamic text />
</LinearLayout>
<TextView
android:id="#+id/abc_explanation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_vertical"
android:text="" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/bottom_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
android:layout_weight="0"
android:orientation="horizontal">
<Button
android:id="#+id/save_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
<Button ... 2>
<Button ... 3>
</LinearLayout>
</LinearLayout>
You have given weight 0 to the linear layout of the buttons. Removing that will fix the issue. Also add 0dp height to ScrollView
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="#+id/layout_scrollview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Notes"
android:textStyle="bold" />
<EditText
android:id="#+id/the_edit_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:hint="Notes"
android:minLines="3"
android:text="" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some static text"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some dynamic text />
</LinearLayout>
<TextView
android:id="#+id/abc_explanation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_vertical"
android:text="" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/bottom_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<Button
android:id="#+id/save_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
<Button ... 2>
<Button ... 3>
</LinearLayout>
Relative Layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="#+id/layout_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_buttons"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Notes"
android:textStyle="bold"/>
<EditText
android:id="#+id/the_edit_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:hint="Notes"
android:minLines="3"
android:text=""/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some static text"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some dynamic text"/>
</LinearLayout>
<TextView
android:id="#+id/abc_explanation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_vertical"
android:text=""/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_alignParentBottom="true"
android:id="#+id/bottom_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<Button
android:id="#+id/save_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save"/>
<Button
android:id="#+id/save_button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save"/>
<Button
android:id="#+id/save_button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save"/>
</LinearLayout>
I tried your code:
Below code is working fine:--
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="horizontal"
tools:context=".RelativeActivity"
android:fillViewport="true">
<ScrollView
android:id="#+id/layout_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="7dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Notes"
android:textStyle="bold" />
<EditText
android:id="#+id/the_edit_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:hint="Notes"
android:minLines="3"
android:text="" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some static text"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some dynamic text" />
</LinearLayout>
<TextView
android:id="#+id/abc_explanation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_vertical"
android:text="" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/bottom_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
android:layout_weight="0"
android:orientation="horizontal">
<Button
android:id="#+id/save_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save1" />
<Button
android:id="#+id/save_button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save2" />
<Button
android:id="#+id/save_button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save3" />
</LinearLayout>
</LinearLayout>
Please check your AndroidManifest.xml.
If there is android:windowSoftInputMode="adjustPan" under your activity like below:
<activity android:name=".RelativeActivity"
android:windowSoftInputMode="adjustPan"/>
Remove android:windowSoftInputMode="adjustPan" from AndroidManifest file under your activity. Because of adjustPan your bottom buttons are disappear when keyboard is open.
I hope its work for you.

Stack two vertical LinearLayout in LinearLayout horizontally

I'm trying to stack two vertical LinearLayout in LinearLayout horizontally.
My code:
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtusername" />
<TextView
android:text="Date registration"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtdateregistr" />
<TextView
android:text="Phone number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtphonenumb" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="horisontal"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercountnumb" />
<TextView
android:text="Ordr"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercount" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycountnumb" />
<TextView
android:text="Delv"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycount" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Also everything looks as I and has conceived:
And the scheme for full understanding:
But when I compile that in VS2015 see error "String types not allowed (at 'orientation' with value 'horisontal')". Need help
Its a typo.
Change,
android:orientation="horisontal"
to
android:orientation="horizontal"
In the root use below attribute
wheightSum="10"
and in child view use wheight = "5" for each child view
Note: on base layout use android:orientation="horizontal" for horizontal display or android:orientation="vertical" for vertical display
Error in LinearLayout orientation.It should be horizontal or remove this.(By default Linear layout has horizontal orientation. )
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtusername" />
<TextView
android:text="Date registration"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtdateregistr" />
<TextView
android:text="Phone number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtphonenumb" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercountnumb" />
<TextView
android:text="Ordr"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercount" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycountnumb" />
<TextView
android:text="Delv"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycount" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

How do i design this screen in android?

How can i create this Layout in android studio? I try to write some codes but i can' t complete that. Thank you for helps. Should i use LinearLayout or RelativeLayout or TableLayout for same viewing for all devices.
http://i.imgur.com/EBd3CAo.png
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:background="#404040">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="59dp"
android:orientation="horizontal"
android:weightSum="1">
<EditText
android:layout_width="198dp"
android:id="#+id/editText"
android:layout_above="#+id/tv1"
android:layout_marginBottom="31dp"
android:text="12345678901"
android:autoText="false"
android:elegantTextHeight="false"
android:maxLength="11"
android:singleLine="true"
android:background="#000000"
android:textColor="#a0a0a0"
android:inputType="number"
android:textSize="40dp"
android:textAlignment="center"
android:textStyle="bold"
android:layout_height="50dp"
android:layout_weight="0.45" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="tv1"
android:id="#+id/tv1"
android:layout_weight="0.36"
android:textColor="#55ff1c"
android:paddingLeft="10dp" />
</LinearLayout>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bla bla bla bla bla"
android:id="#+id/cbx1"
android:checked="false"
android:singleLine="true"
android:textSize="18dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:layout_width="180dp"
android:layout_height="wrap_content"
android:id="#+id/listView" />
<LinearLayout
android:orientation="vertical"
android:layout_width="180dp"
android:layout_height="wrap_content">
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"></RadioGroup>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Change margin/padding/fontsize/color as required
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#404040"
android:orientation="vertical"
android:weightSum="3">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_above="#+id/tv1"
android:autoText="false"
android:background="#000000"
android:elegantTextHeight="false"
android:inputType="number"
android:maxLength="11"
android:singleLine="true"
android:text="12345678901"
android:textAlignment="center"
android:textColor="#a0a0a0"
android:textSize="40dp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="tv1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#55ff1c" />
</LinearLayout>
<CheckBox
android:id="#+id/cbx1"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:singleLine="true"
android:text="bla bla bla bla bla"
android:textSize="18dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="2.8"
android:layout_margin="10dp"
android:layout_height="0dp"
android:orientation="horizontal">
<ListView
android:id="#+id/listView"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton1"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton2"/>
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20sp"
android:text="Text View" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20sp"
android:text="Text View" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:padding="5dp"
android:text="button" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_weight="0.2"
android:layout_margin="10dp"
android:layout_height="wrap_content"
android:text="Bottomtextview"/>
</LinearLayout>
I made a design as you need. But you may need to set height and width by your own. take a look to the below code.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:hint="Edit Text" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Text View" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Check Box" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<ListView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Radio Button" />
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Radio Button" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Text View"
android:textSize="24sp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:text="Text View" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:textSize="24sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Text View"
android:textSize="30sp" />
</LinearLayout>
</LinearLayout>
I designed this by linear layout. hope it helps you.

Using a ScrollView with three LinearLayouts inside

I got a problem with an .xml file of an Android project.
Particularly, I need to have a Scroll View for the major part of the screen a footer underneath.
The ScrollView is the parent of a LinearLayout which keeps three LinearLayouts inside.
The first twos LinearLayout are correctly shown, but the third has never been shown.
I don't understand the reason why it happens: if I put the third LinearLayout in first position, everyone is correctly showed.
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="AppInfo"
android:padding="5dp"
android:id="#+id/bread" />
<HorizontalScrollView
android:id="#+id/horizontal_scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:id="#+id/layout_image_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffffff"
android:gravity="fill_horizontal"
android:layout_gravity="top"
android:id="#+id/attivita_linear"
android:padding="10dp"
android:isScrollContainer="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nome Attività"
android:id="#+id/textView_nome"
android:layout_gravity="center_vertical|center_horizontal"
android:textSize="30dp"
android:paddingBottom="35dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Indirizzo: "
android:id="#+id/textView_indirizzo"
android:textSize="20dp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Telefono: "
android:id="#+id/textView_tel"
android:textSize="20dp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email: "
android:id="#+id/textView_email"
android:textSize="20dp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="www: "
android:id="#+id/textView_www"
android:textSize="20dp"
android:textIsSelectable="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Descrizione: "
android:id="#+id/textView_descrizione"
android:textSize="20dp"
android:textIsSelectable="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#000000"
android:gravity="fill_horizontal"
android:layout_gravity="top"
android:id="#+id/attivita_buttons"
android:padding="10dp"
android:isScrollContainer="true">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"
android:background="#drawable/ic_action_call"
android:contentDescription="prova" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/cola">
</FrameLayout>
</RelativeLayout>
</RelativeLayout>
Hope you can help me.
Any answer would be appreciated.
Set above attribute to your scrollview
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" android:above="#+id/footer">
Bottom part of your ScrollView is getting covered by your footer view. Setting your ScrollView above it will let you scroll entire list.
You can also easily done this using LinearLayout .
Note : textSize value is always given "sp" instead of "dp" for this look at this one Link
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="AppInfo"
android:padding="5dp"
android:id="#+id/bread" />
<HorizontalScrollView
android:id="#+id/horizontal_scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:id="#+id/layout_image_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffffff"
android:gravity="fill_horizontal"
android:layout_gravity="top"
android:id="#+id/attivita_linear"
android:padding="10dp"
android:isScrollContainer="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nome Attività"
android:id="#+id/textView_nome"
android:layout_gravity="center_vertical|center_horizontal"
android:textSize="30sp"
android:paddingBottom="35dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Indirizzo: "
android:id="#+id/textView_indirizzo"
android:textSize="20sp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Telefono: "
android:id="#+id/textView_tel"
android:textSize="20sp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email: "
android:id="#+id/textView_email"
android:textSize="20sp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="www: "
android:id="#+id/textView_www"
android:textSize="20sp"
android:textIsSelectable="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Descrizione: "
android:id="#+id/textView_descrizione"
android:textSize="20sp"
android:textIsSelectable="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#000000"
android:gravity="fill_horizontal"
android:layout_gravity="top"
android:id="#+id/attivita_buttons"
android:padding="10dp"
android:isScrollContainer="true">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"
android:background="#drawable/ic_action_call"
android:contentDescription="prova" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/cola">
</FrameLayout>
</RelativeLayout>
</LinearLayout>

Using DatePicker and TimePicker in same layout

I'm trying to use one date picker and two time picker in the same layout, but only the first one in layout is being displayed. I'm sure something must be wring with my layout but haven't found the error yet.
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B5B5B5"
android:orientation="vertical" >
<include layout="#layout/actionbar_layout" />
<LinearLayout
android:id="#+id/new_conference_date"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_date_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_date_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_date_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_start"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_start_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_start_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_start_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_end"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_end_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="end:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_end_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_end_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
</LinearLayout>
try this one:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B5B5B5"
android:orientation="vertical" >
<include layout="#layout/actionbar_layout" />
<LinearLayout
android:id="#+id/new_conference_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_date_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_date_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_date_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_start_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_start_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_start_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_end_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="end:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_end_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_end_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
I just changed inner LinearLayouts height to wrap_content
You have three LinearLayout with match_parent in layout_width without a weight.
Try adding the next line to those LinearLayout's
android:layout_weight="1"

Categories

Resources