Android Linear Layout issue - android

I have a problem with dividing the LinearLayout(Horizontal) into three columns (vertical columns).
Can someone look into the XML and advise ?
XML below:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="40"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ibTakeCheckPhoto"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:src="#drawable/camera" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:orientation="vertical" >
<TextView
android:id="#+id/checkLayoutIDTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Check Number"
android:textStyle="bold" />
<TextView
android:id="#+id/checkLayout_amountTV"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Amount"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:orientation="vertical" >
<EditText
android:id="#+id/checkLayoutIDET"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Check No."
android:inputType="number" >
</EditText>
<EditText
android:id="#+id/checkLayout_amounET"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:hint="Amount"
android:inputType="number" />
</LinearLayout>

<?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="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="24.33"
android:orientation="vertical" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/checkLayoutIDTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Check Number"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/checkLayout_amountTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Amount"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tableRow6"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:hint="Amount"
android:inputType="number" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/checkLayoutIDET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="edit2"
android:inputType="number" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/checkLayout_amounET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:hint="Amount"
android:inputType="number" >
<requestFocus />
</EditText>
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
may b it fulfill your requirement..

Use android:layout_width="fill_parent" instead of android:layout_width="0dp" in ImageButton, TextView and EditText.
Resulting layout will look like this
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="40"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ibTakeCheckPhoto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:src="#drawable/camera" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="30"
android:orientation="vertical" >
<TextView
android:id="#+id/checkLayoutIDTV"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Check Number"
android:textStyle="bold" />
<TextView
android:id="#+id/checkLayout_amountTV"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Amount"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:orientation="vertical" >
<EditText
android:id="#+id/checkLayoutIDET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Check No."
android:inputType="number" >
</EditText>
<EditText
android:id="#+id/checkLayout_amounET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:hint="Amount"
android:inputType="number" />
</LinearLayout>
</LinearLayout>
And extract hardcoded strings to res/values/strings.xml

i think this is what you wanted
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="10" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ibTakeCheckPhoto"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="left"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical" >
<TextView
android:id="#+id/checkLayoutIDTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Check Number"
android:textStyle="bold" />
<TextView
android:id="#+id/checkLayout_amountTV"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Amount"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical" >
<EditText
android:id="#+id/checkLayoutIDET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Check No."
android:inputType="number" >
</EditText>
<EditText
android:id="#+id/checkLayout_amounET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:hint="Amount"
android:inputType="number" />
</LinearLayout>

Related

Android even vertical spacing between widgets

I have a fragment layout that looks like this:
The top 3 rows are spaced nicely, but the age and sex rows are too short vertically. If I were to hard code a vertical size for the entire layout, is there a way to ensure every item is evenly spaced vertically? Currently, due to the different widget types being used, the bottom too dont look very nice
Here is the code for my layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Research Assistant:" />
<EditText
android:id="#+id/input_ra"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="textCapWords"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Subject Number:" />
<EditText
android:id="#+id/input_subnum"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="text"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Condition:" />
<EditText
android:id="#+id/input_condition"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="number"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Age:" />
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/input_age_spinner"
android:layout_weight="0.6" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Sex:" />
<RadioGroup
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:id="#+id/input_button_male"
android:paddingRight="10dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:id="#+id/input_button_female"
android:paddingRight="10dp"/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="50dp">
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:orientation="horizontal" >
<Button
android:id="#+id/input_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Save" />
<Button
android:id="#+id/input_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Reset" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Try this. Each row view is equally apart from each other.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="20dp"
android:weightSum="12"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="2" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Research Assistant:" />
<EditText
android:id="#+id/input_ra"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:textAppearance="#android:style/TextAppearance.Medium"
android:ems="10"
android:inputType="textCapWords"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="2"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Subject Number:" />
<EditText
android:id="#+id/input_subnum"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="text"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:gravity="center"
android:layout_weight="2"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Condition:" />
<EditText
android:id="#+id/input_condition"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="number"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="2"
android:gravity="center"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Age:" />
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/input_age_spinner"
android:layout_weight="0.6" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="2"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Sex:" />
<RadioGroup
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:id="#+id/input_button_male"
android:paddingRight="10dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:id="#+id/input_button_female"
android:paddingRight="10dp"/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:gravity="center"
android:layout_weight="2"
android:weightSum="1">
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="0.75"
android:orientation="horizontal" >
<Button
android:id="#+id/input_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Save" />
<Button
android:id="#+id/input_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Reset" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Hope this works for you.
Perhaps you could consider using weightSum and weight attribute to evenly distribute it.
Below is the edited code based on that. Noted your height would be now 0dp, and I give more weight to the last buttons.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="10"
android:padding="20dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Research Assistant:" />
<EditText
android:id="#+id/input_ra"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="textCapWords"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Subject Number:" />
<EditText
android:id="#+id/input_subnum"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="text"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Condition:" />
<EditText
android:id="#+id/input_condition"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:ems="10"
android:inputType="number"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Age:" />
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/input_age_spinner"
android:layout_weight="0.6" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Sex:" />
<RadioGroup
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:id="#+id/input_button_male"
android:paddingRight="10dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:id="#+id/input_button_female"
android:paddingRight="10dp"/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:paddingTop="50dp"
android:orientation="horizontal">
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:orientation="horizontal" >
<Button
android:id="#+id/input_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Save" />
<Button
android:id="#+id/input_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:text="Reset" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

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.

Contents in ListView not centered

My app retrieves user details from DB and displays in the ListView. However the contents displayed in the ListView are not formatted properly.
This is how my layout is currently rendered:
This is my layout file for the activity:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
tools:context=".LeaderBoard" >
<LinearLayout
android:id="#+id/column"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/column_header1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="#string/strLBoardHeaderRank"
android:textColor="#f00"
android:textSize="24sp" />
<TextView
android:id="#+id/column_header2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:text="#string/strLBoardHeaderName"
android:layout_gravity="center"
android:textColor="#f00"
android:textSize="24sp" />
<TextView
android:id="#+id/column_header3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="#string/strLBoardHeaderScore"
android:textColor="#f00"
android:textSize="24sp" />
</LinearLayout>
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/column" >
</ListView>
</RelativeLayout>
The layout file for the list activity is below:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000" >
<TextView
android:id="#+id/rank"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:textColor="#f00"
android:textSize="20sp" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:textColor="#f00"
android:textSize="20sp" />
<TextView
android:id="#+id/score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:textColor="#f00"
android:textSize="20sp" />
</LinearLayout>
add android:gravity="center" for all textviews and layout file for the list activity textviews width should be 0dp because of weight property and u should also add android:orientation="horizontal"
<TextView
android:id="#+id/column_header1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:gravity="center"
android:text="strLBoardHeaderRank"
android:textColor="#f00"
android:textSize="24sp" />
<TextView
android:id="#+id/column_header2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:gravity="center"
android:text="strLBoardHeaderName"
android:layout_gravity="center"
android:textColor="#f00"
android:textSize="24sp" />
<TextView
android:id="#+id/column_header3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:gravity="center"
android:text="strLBoardHeaderScore"
android:textColor="#f00"
android:textSize="24sp" />
layout file for the list
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="horizontal" >
<TextView
android:id="#+id/rank"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:gravity="center"
android:textColor="#f00"
android:textSize="20sp" />
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:gravity="center"
android:textColor="#f00"
android:textSize="20sp" />
<TextView
android:id="#+id/score"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:gravity="center"
android:textColor="#f00"
android:textSize="20sp" />
</LinearLayout>
Try this one, this worked for me
//Main Layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="horizontal" >
<TableLayout
android:id="#+id/add_rule_table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginTop="5dp"
android:background="#color/list_divider"
android:orientation="vertical"
android:stretchColumns="*"
android:visibility="gone" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/list_divider"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/list_divider"
android:ems="4"
android:gravity="center"
android:text="#string/rule_no"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/list_divider"
android:ems="4"
android:gravity="center"
android:text="#string/lot"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/list_divider"
android:ems="4"
android:gravity="center"
android:text="#string/discount"
android:textSize="12sp"
android:textStyle="bold" />
</TableRow>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#color/list_divider" />
</TableLayout>
<ListView
android:id="#+id/rule_list_view"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_weight="1"
android:background="#android:color/transparent"
android:cacheColorHint="#00000000"
android:choiceMode="none"
android:listSelector="#android:color/transparent" />
</LinearLayout>
//Custom List View Items
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
>
<TableLayout
android:id="#+id/add_rule_table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginTop="5dp"
android:background="#color/white"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="horizontal" >
<TextView
android:id="#+id/rule_nos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:layout_marginRight="1dp"
android:ems="3"
android:gravity="center_horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="1"
android:textSize="12sp" />
<TextView
android:id="#+id/lots"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="23"
android:textSize="12sp" />
<TextView
android:id="#+id/discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="34%"
android:textSize="12sp" />
<TextView
android:id="#+id/edit_rule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/edit_rule"
android:ems="4"
android:gravity="center_horizontal"
android:text="#string/edit"
android:textColor="#ffffff"
android:textSize="12sp" />
<TextView
android:id="#+id/delete_rule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:background="#drawable/delete_rule"
android:ems="4"
android:gravity="center_horizontal"
android:text="#string/delete"
android:textColor="#ffffff"
android:textSize="12sp" />
</TableRow>
</TableLayout>
</LinearLayout>

Related to android layout

This is my Apps login page . problem with that is when i run app on larger screens phones it is ok with that but smaller screens are not showing my button . what is wrong with my xml. i have to use scrolls or some other solution exists. I did not use any absolute values so why i am having this problems.
<?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:weightSum=".5"
android:orientation="vertical"
android:background="#drawable/bg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".1"
android:gravity="bottom|center"
android:orientation="horizontal"
android:layout_margin="8sp" >
<ImageView
android:id="#+id/imgid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/logo" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8sp"
android:layout_weight=".1"
android:gravity="bottom"
android:orientation="horizontal"
android:weightSum="5" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:id="#+id/edtpinid1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:inputType="number"
android:maxLength="1"
android:gravity="center"
android:textColor="#222222"
android:paddingBottom="5sp"
android:paddingTop="3sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginLeft="15sp">
<EditText
android:id="#+id/edtpinid2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:inputType="number"
android:maxLength="1"
android:gravity="center"
android:textColor="#222222"
android:paddingBottom="5sp"
android:paddingTop="3sp"
>
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginLeft="15sp">
<EditText
android:id="#+id/edtpinid3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:inputType="number"
android:maxLength="1"
android:gravity="center"
android:textColor="#222222"
android:paddingBottom="5sp"
android:paddingTop="3sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginLeft="15sp">
<EditText
android:id="#+id/edtpinid4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:inputType="number"
android:maxLength="1"
android:gravity="center"
android:textColor="#222222"
android:paddingBottom="5sp"
android:paddingTop="3sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15sp"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginLeft="15sp" >
<EditText
android:id="#+id/edtpinid5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:inputType="number"
android:maxLength="1"
android:gravity="center"
android:textColor="#222222"
android:paddingBottom="5sp"
android:paddingTop="3sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8sp"
android:layout_weight=".3"
android:orientation="vertical"
android:padding="12sp" >
<Button
android:id="#+id/buttonid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/button"
android:layout_marginLeft="5sp"
android:layout_marginRight="5sp"
android:text="Login"
android:textColor="#fff"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18sp"
android:layout_marginLeft="15sp"
android:layout_marginRight="15sp"
android:weightSum="2" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<TextView
android:id="#+id/txtNewUserID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New User? SignUp" /></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
>
<TextView
android:id="#+id/txtforgetID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot PIN?" /></LinearLayout></LinearLayout>
</LinearLayout>
</LinearLayout>
the button is not appearing on smaller screens . any on can help me out of this. what can i do to resize automatically my layout to as screen of mobile. i have to use scrolls or some other solution exists. I did not use any absolute values so why i am having this problems.
Use below code, that will work in all device, Added ScrollView for scroling issue
<?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="#drawable/bg"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum=".5" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8sp"
android:layout_weight=".1"
android:gravity="bottom|center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/logo" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8sp"
android:layout_weight=".1"
android:gravity="bottom"
android:orientation="horizontal"
android:weightSum="5" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:id="#+id/edtpinid1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:gravity="center"
android:inputType="number"
android:maxLength="1"
android:paddingBottom="5sp"
android:paddingTop="3sp"
android:textColor="#222222" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:id="#+id/edtpinid2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:gravity="center"
android:inputType="number"
android:maxLength="1"
android:paddingBottom="5sp"
android:paddingTop="3sp"
android:textColor="#222222" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:id="#+id/edtpinid3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:gravity="center"
android:inputType="number"
android:maxLength="1"
android:paddingBottom="5sp"
android:paddingTop="3sp"
android:textColor="#222222" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:id="#+id/edtpinid4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:gravity="center"
android:inputType="number"
android:maxLength="1"
android:paddingBottom="5sp"
android:paddingTop="3sp"
android:textColor="#222222" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:layout_marginRight="15sp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:id="#+id/edtpinid5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bg"
android:gravity="center"
android:inputType="number"
android:maxLength="1"
android:paddingBottom="5sp"
android:paddingTop="3sp"
android:textColor="#222222" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8sp"
android:layout_weight=".3"
android:orientation="vertical"
android:padding="12sp" >
<Button
android:id="#+id/buttonid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5sp"
android:layout_marginRight="5sp"
android:background="#drawable/button"
android:text="Login"
android:textColor="#fff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:layout_marginRight="15sp"
android:layout_marginTop="18sp"
android:weightSum="2" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/txtNewUserID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New User? SignUp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right" >
<TextView
android:id="#+id/txtforgetID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot PIN?" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
you are using orentation verticle and weight property so u have give
android:layout_height="0dp"
insted
android:layout_height="wrap_content"
for ue child linear laouts only which are considered in verticle
hope it works for u..
use scrollView for the parent layout
Why are you using "sp" sp is more suitable for text, try using dp

Full page size not showing when keypad is up in android

I have 5 edittext and 3 button in an xml fil.
When I focus on the first edittext, the scroll is only going half way but not showing till the end.
I have tried
android:windowSoftInputMode="adjustPan"
and the
android:windowSoftInputMode="stateAlwaysVisible"
but when i put this state always visible the problem is i hav tabs in my page that tabs will also jump up when i focus in one edittext
can anybody help!!
<?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="#drawable/bg"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#517eb9" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/Detail_page"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dip"
android:gravity="center" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/pro_infotwo"
android:textColor="#d51302"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<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"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="#string/prodet_id"
android:textSize="18sp"
android:textStyle="bold" />
<EditText
android:id="#+id/ppid"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_marginTop="20dip"
android:layout_weight="0.5"
android:background="#drawable/edittext"
android:ems="10"
android:paddingLeft="5dip" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="#string/keywords"
android:textSize="18sp"
android:textStyle="bold" />
<EditText
android:id="#+id/pp_key"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="#drawable/edittext"
android:ems="10"
android:paddingLeft="5dip" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="#string/prodet_cat1"
android:textSize="18sp"
android:textStyle="bold" />
<EditText
android:id="#+id/pp_cat"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="#drawable/edittext"
android:ems="10"
android:paddingLeft="5dip" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="#string/prodet_cat2"
android:textSize="18sp"
android:textStyle="bold" />
<EditText
android:id="#+id/pp_cat2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="#drawable/edittext"
android:ems="10"
android:paddingLeft="5dip" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="#string/vid_url"
android:textSize="18sp"
android:textStyle="bold" />
<EditText
android:id="#+id/pp_url"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="#drawable/edittext"
android:ems="10"
android:paddingLeft="5dip" />
</LinearLayout>
<Button
android:id="#+id/Proceed_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dip"
android:layout_marginBottom="20dip"
android:background="#d51302"
android:padding="10dip"
android:text="#string/proceed"
android:textColor="#android:color/white" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Thanks in advance

Categories

Resources