Top views in scrollView are not visible in landscape screen - android

The problem is that in landscape screen position
I can't slide to see top textView.
And the image on the top is visible only partly.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backNormal"
android:orientation="vertical"
>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backNormal"
android:orientation="vertical"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/backNormal"
android:orientation="vertical"
android:layout_gravity="center_horizontal|center_vertical"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/backNormal"
android:orientation="horizontal"
android:layout_gravity="center_horizontal|center_vertical"
android:weightSum="6"
>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/backNormal"
android:orientation="vertical"
android:layout_weight="4"
android:layout_gravity="center_horizontal|center_vertical"
>
<TextView
android:id="#+id/textNameTitle"
android:gravity="center"
android:text='Your profile'
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/text_style_title"
/>
<ImageView
android:id="#+id/imageNameAvatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_centerHorizontal="true"
android:src="#drawable/clip32"
/>
<EditText
android:id="#+id/editName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="1"
android:minLines="1"
android:maxLines="1"
android:maxLength="25"
style="#style/edit_style"
android:layout_gravity="left"
android:background="#drawable/edit"
android:inputType="textCapSentences"
android:cursorVisible="true"
android:textCursorDrawable="#null"
/>
<TextView
android:id="#+id/textInfoGenderTitle"
android:gravity="center"
android:text='Gender'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
style="#style/text_style_normal"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:weightSum="4"
>
<Button
android:id="#+id/buttonInfoMale"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text='M'
style="#style/button_style_normal"
/>
<TextView
android:id="#+id/textInfoGender"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center"
android:text='Unknown'
android:background="#color/backDark1"
style="#style/text_style_normal"
/>
<Button
android:id="#+id/buttonInfoFemale"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text='F'
style="#style/button_style_normal"
/>
</LinearLayout>
<TextView
android:id="#+id/textInfoYearTitle"
android:gravity="center"
android:text='Year'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
style="#style/text_style_normal"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:weightSum="4"
>
<Button
android:id="#+id/buttonInfoYearMinus"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text='-'
style="#style/button_style_normal"
/>
<TextView
android:id="#+id/textInfoYear"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center"
android:text='Unknown'
android:background="#color/backDark1"
style="#style/text_style_normal"
/>
<Button
android:id="#+id/buttonInfoYearPlus"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text='+'
style="#style/button_style_normal"
/>
</LinearLayout>
<ProgressBar
android:id="#+id/progressBarName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity= "center_vertical|center_horizontal"
/>
<Button
android:id="#+id/buttonNameReg"
android:text='Registration'
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
style="#style/button_style_normal"
/>
<TextView
android:id="#+id/textNameResult"
android:gravity="center"
android:text=''
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/text_style_normal"
/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Any advices please! Thanks!
Sorry for the text below.
The site said that my post is mostly code...
text text text text
text text
text text

Related

Some views in layout are outside the screen

Top text "Your profile" is not visible in my layout.
In album orientation pictures are truncated.
I have added "Scroll" element, but it does not work there.
My XML is below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backNormal"
android:orientation="vertical"
>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backNormal"
android:orientation="vertical"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/backNormal"
android:orientation="vertical"
android:layout_gravity="center_horizontal|center_vertical"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/backNormal"
android:orientation="horizontal"
android:layout_gravity="center_horizontal|center_vertical"
android:weightSum="6"
>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/backNormal"
android:orientation="vertical"
android:layout_weight="4"
android:layout_gravity="center_horizontal|center_vertical"
>
<TextView
android:id="#+id/driverProfileTextTitle"
android:gravity="center"
android:text='Your profile'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
style="#style/text_style_title"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/driverProfileImageFace"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:src="#drawable/driver"
android:adjustViewBounds="true"
/>
<ImageView
android:id="#+id/driverProfileImageCar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:src="#drawable/car"
android:adjustViewBounds="true"
/>
</LinearLayout>
<TextView
android:id="#+id/driverProfileTextName"
android:gravity="center"
android:text='Your name'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
style="#style/text_style_normal"
/>
<EditText
android:id="#+id/driverProfileEditName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="1"
android:minLines="1"
android:maxLines="1"
android:maxLength="25"
style="#style/edit_style"
android:layout_gravity="left"
android:background="#drawable/edit"
android:inputType="textCapSentences"
android:cursorVisible="true"
/>
<TextView
android:id="#+id/driverProfileTextCar"
android:gravity="center"
android:text='Car model and number'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
style="#style/text_style_normal"
/>
<EditText
android:id="#+id/driverProfileEditCar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="1"
android:minLines="1"
android:maxLines="1"
android:maxLength="25"
style="#style/edit_style"
android:layout_gravity="left"
android:background="#drawable/edit"
android:inputType="textCapSentences"
android:cursorVisible="true"
/>
<TextView
android:id="#+id/driverProfileTextGenderTitle"
android:gravity="center"
android:text='Gender'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
style="#style/text_style_normal"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:weightSum="4"
>
<Button
android:id="#+id/driverProfileButtonMale"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text='M'
style="#style/button_style_normal"
/>
<TextView
android:id="#+id/driverProfileTextGender"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center"
android:text='Unknown'
android:background="#color/backDark1"
style="#style/text_style_normal"
/>
<Button
android:id="#+id/driverProfileButtonFemale"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text='F'
style="#style/button_style_normal"
/>
</LinearLayout>
<TextView
android:id="#+id/driverProfileTextYearTitle"
android:gravity="center"
android:text='Year Of Birth'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
style="#style/text_style_normal"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:weightSum="4"
>
<Button
android:id="#+id/driverProfileButtonYearMinus"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text='-'
style="#style/button_style_normal"
/>
<TextView
android:id="#+id/driverProfileTextYear"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center"
android:text='Unknown'
android:background="#color/backDark1"
style="#style/text_style_normal"
/>
<Button
android:id="#+id/driverProfileButtonYearPlus"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text='+'
style="#style/button_style_normal"
/>
</LinearLayout>
<ProgressBar
android:id="#+id/driverProfileProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
/>
<Button
android:id="#+id/driverProfileButtonReg"
android:text='Registration'
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
style="#style/button_style_normal"
/>
<TextView
android:id="#+id/driverProfileTextResult"
android:gravity="center"
android:text=''
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/text_style_normal"
/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="5dp"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Any ideas please?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backNormal"
android:orientation="vertical"
android:fillViewport="true" >
Rest of the code
Use ScrollView as a parent.
I think this can help you.
Try this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="8dp"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#color/backNormal"
android:layout_gravity="center_horizontal|center_vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal|center_vertical"
android:weightSum="6"
>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="4"
android:layout_gravity="center_horizontal|center_vertical"
>
<TextView
android:id="#+id/driverProfileTextTitle"
android:gravity="center"
android:text='Your profile'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
style="#style/text_style_title"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/driverProfileImageFace"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:src="#drawable/driver"
android:adjustViewBounds="true"
/>
<ImageView
android:id="#+id/driverProfileImageCar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:src="#drawable/car"
android:adjustViewBounds="true"
/>
</LinearLayout>
<TextView
android:id="#+id/driverProfileTextName"
android:gravity="center"
android:text='Your name'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
style="#style/text_style_normal"
/>
<EditText
android:id="#+id/driverProfileEditName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="1"
android:minLines="1"
android:maxLines="1"
android:maxLength="25"
style="#style/edit_style"
android:layout_gravity="left"
android:background="#drawable/edit"
android:inputType="textCapSentences"
android:cursorVisible="true"
/>
<TextView
android:id="#+id/driverProfileTextCar"
android:gravity="center"
android:text='Car model and number'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
style="#style/text_style_normal"
/>
<EditText
android:id="#+id/driverProfileEditCar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="1"
android:minLines="1"
android:maxLines="1"
android:maxLength="25"
style="#style/edit_style"
android:layout_gravity="left"
android:background="#drawable/edit"
android:inputType="textCapSentences"
android:cursorVisible="true"
/>
<TextView
android:id="#+id/driverProfileTextGenderTitle"
android:gravity="center"
android:text='Gender'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
style="#style/text_style_normal"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:weightSum="4"
>
<Button
android:id="#+id/driverProfileButtonMale"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text='M'
style="#style/button_style_normal"
/>
<TextView
android:id="#+id/driverProfileTextGender"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center"
android:text='Unknown'
android:background="#color/backDark1"
style="#style/text_style_normal"
/>
<Button
android:id="#+id/driverProfileButtonFemale"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text='F'
style="#style/button_style_normal"
/>
</LinearLayout>
<TextView
android:id="#+id/driverProfileTextYearTitle"
android:gravity="center"
android:text='Year Of Birth'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
style="#style/text_style_normal"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:weightSum="4"
>
<Button
android:id="#+id/driverProfileButtonYearMinus"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text='-'
style="#style/button_style_normal"
/>
<TextView
android:id="#+id/driverProfileTextYear"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center"
android:text='Unknown'
android:background="#color/backDark1"
style="#style/text_style_normal"
/>
<Button
android:id="#+id/driverProfileButtonYearPlus"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:text='+'
style="#style/button_style_normal"
/>
</LinearLayout>
<ProgressBar
android:id="#+id/driverProfileProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
/>
<Button
android:id="#+id/driverProfileButtonReg"
android:text='Registration'
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
style="#style/button_style_normal"
/>
<TextView
android:id="#+id/driverProfileTextResult"
android:gravity="center"
android:text=''
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/text_style_normal"
/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="5dp"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
but you need improve your layout with more RelativeLayout instead of LinearLayout, and also deep layout level will reduce performance
Use android:fillViewport="true" in your ScrollView and it will fill up the screen.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
Try this
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backNormal"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:background="#color/backNormal"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:background="#color/backNormal"
android:orientation="horizontal"
android:weightSum="6" >
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="4"
android:background="#color/backNormal"
android:orientation="vertical" >
<TextView
android:id="#+id/driverProfileTextTitle"
style="#style/text_style_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="Your profile" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/driverProfileImageFace"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/driver" />
<ImageView
android:id="#+id/driverProfileImageCar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/car" />
</LinearLayout>
<TextView
android:id="#+id/driverProfileTextName"
style="#style/text_style_normal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="Your name" />
<EditText
android:id="#+id/driverProfileEditName"
style="#style/edit_style"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:background="#drawable/edit"
android:cursorVisible="true"
android:inputType="textCapSentences"
android:lines="1"
android:maxLength="25"
android:maxLines="1"
android:minLines="1" />
<TextView
android:id="#+id/driverProfileTextCar"
style="#style/text_style_normal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="Car model and number" />
<EditText
android:id="#+id/driverProfileEditCar"
style="#style/edit_style"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:background="#drawable/edit"
android:cursorVisible="true"
android:inputType="textCapSentences"
android:lines="1"
android:maxLength="25"
android:maxLines="1"
android:minLines="1" />
<TextView
android:id="#+id/driverProfileTextGenderTitle"
style="#style/text_style_normal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="Gender" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum="4" >
<Button
android:id="#+id/driverProfileButtonMale"
style="#style/button_style_normal"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="M" />
<TextView
android:id="#+id/driverProfileTextGender"
style="#style/text_style_normal"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#color/backDark1"
android:gravity="center"
android:text="Unknown" />
<Button
android:id="#+id/driverProfileButtonFemale"
style="#style/button_style_normal"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="F" />
</LinearLayout>
<TextView
android:id="#+id/driverProfileTextYearTitle"
style="#style/text_style_normal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="Year Of Birth" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum="4" >
<Button
android:id="#+id/driverProfileButtonYearMinus"
style="#style/button_style_normal"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="-" />
<TextView
android:id="#+id/driverProfileTextYear"
style="#style/text_style_normal"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#color/backDark1"
android:gravity="center"
android:text="Unknown" />
<Button
android:id="#+id/driverProfileButtonYearPlus"
style="#style/button_style_normal"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="+" />
</LinearLayout>
<ProgressBar
android:id="#+id/driverProfileProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/driverProfileButtonReg"
style="#style/button_style_normal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="Registration" />
<TextView
android:id="#+id/driverProfileTextResult"
style="#style/text_style_normal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</ScrollView>
I don't have enough reputation to comment, but using ScrollView as parent and android:fillViewport="true" should solve your issue. If it is not specify whether you are able Scroll after adding ScrollView as parent.

When focus on the edite text resize layout

when i press on the edit text the layout become re-size. What i want is not to change the layout size when i press on the keyboard
I tried
android:windowSoftInputMode="stateVisible|adjustPan"
Refer from below link
http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
Don't make any difference
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bbbbbb"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".1"
android:background="#0486CC" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".34"
android:src="#drawable/logo" />
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".32" />
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".16"
android:background="#drawable/newmenu"
android:onClick="MenuStaffBtnClick" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".18"
android:background="#drawable/menu_sync"
android:onClick="MenuSynBtnClick" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".2" >
<EditText
android:id="#+id/etNamecheck"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight=".6"
android:ems="10"
android:hint="Name" />
<RadioGroup
android:id="#+id/rgSearch"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".4"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/rbID"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/rbName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".7"
android:orientation="vertical" >
<ListView
android:id="#+id/LVitems"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#bbbbbb"
android:dividerHeight="5dp" >
</ListView>
</LinearLayout>
try this layout code and add android:windowSoftInputMode="stateVisible|adjustPan" in android manifest file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ScrollView
android:id="#+id/scrolllayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SignIn"
android:textColor="#000000"
android:layout_marginTop="10dp"
android:textSize="20dp"
/>
<EditText
android:id="#+id/userid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#000000"
android:hint="type username" />
<EditText
android:id="#+id/passwordid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="type password"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#000000"
android:inputType="textPassword" />
<Button
android:id="#+id/loginid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#color/list_item_title"
android:text="Signin"
android:textSize="20dp"
android:background="#drawable/btngradient"
/>
<Button android:id="#+id/registerid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dip"
android:textSize="20dp"
android:text=" Register"
android:gravity="center"
android:background="#drawable/btngradient"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp"
android:textColor="#FFFFFF"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>

Android : prevent edittext from hiding behind keyboard without changing manifest

Soft keyboard hides my edit text
this is my layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#F7F7F7"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:background="#C2C2C2"
android:orientation="horizontal"
android:weightSum="1" >
<LinearLayout
android:id="#+id/toggle1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="20dp"
android:layout_height="15dp"
android:src="#drawable/img1" />
</LinearLayout>
<LinearLayout
android:id="#+id/toggle2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="20dp"
android:layout_height="25dp"
android:src="#drawable/img2" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.65"
android:weightSum="1" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text=""
android:textColor="#000"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/list1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.15"
android:background="#EEEEEE"
android:padding="5dp"
android:weightSum="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="1" >
<EditText
android:id="#+id/addCmntTextField"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginTop="2dp"
android:layout_weight="0.8"
android:hint="Add a Comment"
android:text=""
android:textSize="11dp" />
<Button
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_marginLeft="5dp"
android:layout_weight="0.2"
android:text="Save"
android:clickable="true" />
</LinearLayout>
</LinearLayout>
in my menifest is wrote android:windowSoftInputMode="stateHidden" and i cant change it otherwise it will efect my app.How can i do it please help.
This is my complete code
Just implement a nesting in Layouts and this will solve the problem. Try doing this:
<?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:background="#color/white">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="20dp"
android:gravity="bottom"
android:weightSum="1">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id=#+id/addCmntTextField"
android:layout_weight="1"
android:hint="Add a Comment"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:id="#+id/saveComment"/>
</LinearLayout>
</LinearLayout>
Here is the solution that worked for me on samsung galaxy tab
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#F7F7F7"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#C2C2C2"
android:orientation="horizontal"
android:weightSum="1" >
<LinearLayout
android:id="#+id/toggle1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="20dp"
android:layout_height="15dp"
android:src="#drawable/img1" />
</LinearLayout>
<LinearLayout
android:id="#+id/toggle2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="20dp"
android:layout_height="25dp"
android:src="#drawable/img2" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:weightSum="1" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text=""
android:textColor="#000"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/list1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="75dp"
android:background="#EEEEEE"
android:padding="5dp"
android:weightSum="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="1" >
<EditText
android:id="#+id/addCmntTextField"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginTop="2dp"
android:layout_weight="0.8"
android:hint="Add a Comment"
android:text=""
android:textSize="11dp" />
<Button
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_marginLeft="5dp"
android:layout_weight="0.2"
android:text="Save"
android:clickable="true" />
</LinearLayout>
</LinearLayout>

layout buttons are not the same size in android

I have two questions, the first is that I would like the buttons to be on the bottom corner of the screen stacked like they are (they currently are in the middle) and I would like them to be the same size, currently the top 2 buttons are bigger then the bottom two buttons. Also maybe lowering the texview boxes down a little if that is easy enough.
<?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" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center" >
<EditText
android:id="#+id/playerLifeOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:inputType="number"
android:minWidth="120dp"
android:text="20"
android:textSize="40dp" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/badd1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="+1" />
<Button
android:id="#+id/badd5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="+5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/bsub1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-1" />
<Button
android:id="#+id/bsub5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-5" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center" >
<EditText
android:id="#+id/playerLifeTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:inputType="number"
android:minWidth="120dp"
android:text="20"
android:textSize="40dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="right"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/b2add1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="+1" />
<Button
android:id="#+id/b2add5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="+5" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/b2sub1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-1" />
<Button
android:id="#+id/b2sub5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-5" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Check now.
<?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" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center" >
<EditText
android:id="#+id/playerLifeOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="50dp"
android:inputType="number"
android:minWidth="120dp"
android:text="20"
android:textSize="40dp" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/badd1"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="+1" />
<Button
android:id="#+id/badd5"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="+5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/bsub1"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="-1" />
<Button
android:id="#+id/bsub5"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="-5" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center" >
<EditText
android:id="#+id/playerLifeTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="50dp"
android:inputType="number"
android:minWidth="120dp"
android:text="20"
android:textSize="40dp" />
</LinearLayout>
<LinearLayout
android:layout_width="156dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/b2add1"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="+1" />
<Button
android:id="#+id/b2add5"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="+5" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/b2sub1"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="-1" />
<Button
android:id="#+id/b2sub5"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:text="-5" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
All buttons should look like this one.-
<Button
android:id="#+id/badd5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="+5" />
Check layout_width and layout_weight properties.
As for the EditTexts, you have several options, an easy one would be applying some top margin.-
<EditText
android:id="#+id/playerLifeOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:gravity="center"
android:inputType="number"
android:minWidth="120dp"
android:text="20"
android:textSize="40dp" >
just a tip: using a RelativeLayout would give you more flexibility and a more simple possibility to achieve what you need.
Note: in my sample project the Holo.Light theme is applied, that's why it looks a bit different.
<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"
tools:context=".MainActivity" >
<!-- this is a SAMPLE layout. Adjust the values as you need them. -->
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="#000000"
android:orientation="vertical" >
</LinearLayout>
<EditText
android:id="#+id/editText1"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp"
android:ems="10" >
</EditText>
<EditText
android:id="#+id/editText2"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignBaseline="#+id/editText1"
android:layout_alignBottom="#+id/editText1"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:ems="10" >
<requestFocus />
</EditText>
<!-- do the same thing on the right side -->
<Button
android:id="#+id/btnMinOneLeft"
android:layout_width="50dp"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="-1" />
<Button
android:id="#+id/btnMinFiveLeft"
android:layout_width="50dp"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/btnMinOneLeft"
android:text="-5" />
<Button
android:id="#+id/btnPlusOneLeft"
android:layout_width="50dp"
android:layout_height="60dp"
android:layout_above="#+id/btnMinOneLeft"
android:layout_alignParentLeft="true"
android:text="+1" />
<Button
android:id="#+id/btnPlusFiveLeft"
android:layout_width="50dp"
android:layout_height="60dp"
android:layout_above="#+id/btnMinFiveLeft"
android:text="+5"
android:layout_toRightOf="#+id/btnPlusOneLeft"/>

LinearLayout not rendering

I want to create a login screen. I want to have the heading at the top, leave some white space and then have the user name and passwords each in one line. Then, I want to leave some more white space at the bottom.
Currently, I haven't tried to put the password TextView and EditTect in a single line because there is some error with the LinearLayout corresponding to the user name due to which it is not rendering. Could you please help me figure out? My XML file is below -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:gravity="center_horizontal"
android:text="#string/welcome_message"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="4" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="4"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="User Name" />
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="0sp"
android:layout_weight="1"
android:text="Password" />
<EditText
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="1"
android:inputType="textPassword" />
<View
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="4" />
</LinearLayout>
Take a look if this what are you looking for:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="0.5" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="3"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="welcome_message"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="1" >
<TextView
android:id="#+id/text_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:lines="1"
android:text="Login:"
android:textSize="13dp" />
<EditText
android:id="#+id/edt_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="0.2"
android:ems="10" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="4" >
<TextView
android:id="#+id/text_senha"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:maxLines="1"
android:text="Senha:" />
<EditText
android:id="#+id/edt_senha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="0.2"
android:ems="10"
android:inputType="textPassword" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="0.5" />
</LinearLayout>
use layout margin and padding settings to leaving space for views.
i recommend using relative layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2"
android:layout_marginTop="30dip"
android:gravity="center_horizontal"
android:text="welcome_message"
android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="4" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:padding="10dip"
android:weightSum="2"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="User Name" />
<EditText
android:layout_width="wrap_content" android:layout_weight="1"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:padding="10dip"
android:weightSum="2"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Password" />
<EditText
android:layout_width="wrap_content" android:layout_weight="1"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

Categories

Resources