Android xml layout about spinner,textview and imageview - android

I am trying to create a certain layout,I hope it same as picture.
But textview and imageview layout are ran out boundaries.
How can I fix it ?
I hope textview and imageview can under spinner.
This is my current code,thanks
<?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="100dp"
android:orientation="horizontal" >
<Spinner
android:id="#+id/spinner_show"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15px"
android:drawSelectorOnTop="true" />
<ImageView
android:id="#+id/icon1"
android:layout_marginTop="130px"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerVertical="true"
android:background="#777"
android:contentDescription="#string/app_name"
android:padding="3dp" />
<LinearLayout
android:layout_width="185dp"
android:layout_height="86dp"
android:layout_marginTop="130px"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="#+id/itemname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:maxLines="3"
android:text="#string/itemname"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:id="#+id/detil"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="1"
android:text="#string/detil"
android:textColor="#android:color/black"
android:textSize="12dp" />
</LinearLayout>
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/app_name"
android:src="#drawable/arrow_next" />
</LinearLayout>

You can try as follows...
<?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="wrap_content"
android:orientation="vertical" >
<Spinner
android:id="#+id/spinner_show"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15px"
android:drawSelectorOnTop="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/icon1"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="#777"
android:contentDescription="#string/app_name"
android:padding="3dp" />
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/itemname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:maxLines="3"
android:text="#string/itemname"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:id="#+id/detil"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="1"
android:text="#string/detil"
android:textColor="#android:color/black"
android:textSize="12dp" />
</LinearLayout>
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_marginRight="5dp"
android:contentDescription="#string/app_name"
android:src="#drawable/arrow_next" />
</LinearLayout>
</LinearLayout>

try this..........
<?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="fill_parent"
android:orientation="vertical" >
<Spinner
android:id="#+id/spinner_show"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15px"
android:drawSelectorOnTop="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_marginTop="100px"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/icon1"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="#777"
android:contentDescription="#string/app_name"
android:padding="3dp" />
<LinearLayout
android:layout_width="185dp"
android:layout_height="86dp"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="#+id/itemname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:maxLines="3"
android:text="itemname"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:id="#+id/detil"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="1"
android:text="detil"
android:textColor="#android:color/black"
android:textSize="12dp" />
</LinearLayout>
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:contentDescription="#string/app_name"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>

here is your 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:orientation="vertical" >
<Spinner
android:id="#+id/spinner_show"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15px"
android:drawSelectorOnTop="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="3" >
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#ababab" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/itemname"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="hello text"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/detil"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="hello text"
android:textColor="#android:color/black"
android:textSize="12sp" />
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#ababab" />
</LinearLayout>
</LinearLayout>

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.

Two textviews one on left and one on the right side

I trying to make two textviews on same line. One on the left and one on the right. Tried with RelativeLayout with android:layout_alignParentRight="true" and android:layout_alignParentLeft="true" but seems not to work. How can I do this?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/restaurants_buttons">
<ImageView
android:id="#+id/ColPhoto"
android:layout_width="0dp"
android:layout_height="0dp"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="#+id/ColName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:textSize="14sp"
android:textStyle="bold"
android:text=""
/>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:background="#CCCCCC" />
<TextView android:id="#+id/ColPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1"
android:text=""
/>
<TextView android:id="#+id/ColWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:layout_weight="1"
android:text=""
/>
</LinearLayout>
</LinearLayout>
I try to align ColPrice and ColWeight. Also if it's possible with LinearLayout.
Try to wrap those TextViews in a LinearLayout.
Like this:
<ImageView
android:id="#+id/ColPhoto"
android:layout_width="0dp"
android:layout_height="0dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/ColName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:text=""
android:textSize="14sp"
android:textStyle="bold" />
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:background="#CCCCCC" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/ColPrice"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:text="" />
<TextView
android:id="#+id/ColWeight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Try this simple code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/restaurants_buttons">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="27dp"
android:text="TextView" />
</RelativeLayout>
</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="fill_parent"
android:orientation="horizontal" >
<ImageView
android:id="#+id/ColPhoto"
android:layout_width="0dp"
android:layout_height="0dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/ColName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:text=""
android:textSize="14sp"
android:textStyle="bold" />
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:background="#CCCCCC" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/ColPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="ColPrice" />
<TextView
android:id="#+id/ColWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="ColWeight" />
</RelativeLayout>
</LinearLayout>

how to align the button at bottom in linear layout?

I want to keep the adview layout at bottom in linear layout. i tried using gravity and layout_gravity at bottom but its not working,i had attached the code and snapshot too.
please give me any solution
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/linearmainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/inner_screen_bg"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:orientation="horizontal"
android:paddingBottom="10dip"
android:paddingTop="5dip"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical"
android:orientation="vertical" >
<Button
android:id="#+id/fbShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/fb_btn"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/twitterShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/tw_btn"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/revealButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/reveal_btn"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<RelativeLayout
android:id="#+id/imageContainer"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginRight="10dip"
android:layout_marginTop="3dp"
android:layout_weight="60"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/imageView"
android:layout_width="320dip"
android:layout_height="150dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/image5" >
<ImageView
android:id="#+id/correctMark"
android:layout_width="80dip"
android:layout_height="80dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dip"
android:layout_marginLeft="5dip"
android:src="#drawable/cleared_imag"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/ticketCounterContainer"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical"
android:orientation="vertical" >
<Button
android:id="#+id/ticket1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ticket"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/ticket2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ticket"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/ticket3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ticket"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
<EditText
android:id="#+id/movieName"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#id/linear1"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:background="#drawable/input_field"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="10dip" />
<RelativeLayout
android:id="#+id/correctAnswerLayoutContainer"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_below="#id/movieName"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:background="#drawable/circular_rectangle_white_background"
android:paddingLeft="10dip"
android:visibility="gone" >
<LinearLayout
android:id="#+id/hintContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/icon" />
<TextView
android:id="#+id/hintOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="#string/musical_moview_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/icon" />
<TextView
android:id="#+id/hintTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="#string/release_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/icon" />
<TextView
android:id="#+id/hintThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="#string/hint3_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<Button
android:id="#+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dip"
android:layout_weight="1"
android:background="#drawable/next_btn" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="1" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/publisher_id"
ads:loadAdOnCreate="true" />
</LinearLayout>
</LinearLayout>
Try this..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/linearmainlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:orientation="horizontal"
android:paddingBottom="10dip"
android:paddingTop="5dip"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical"
android:orientation="vertical" >
<Button
android:id="#+id/fbShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/twitterShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/revealButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<RelativeLayout
android:id="#+id/imageContainer"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginRight="10dip"
android:layout_marginTop="3dp"
android:layout_weight="60"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/imageView"
android:layout_width="320dip"
android:layout_height="150dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
<ImageView
android:id="#+id/correctMark"
android:layout_width="80dip"
android:layout_height="80dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dip"
android:layout_marginLeft="5dip"
android:src="#drawable/ic_launcher"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/ticketCounterContainer"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical"
android:orientation="vertical" >
<Button
android:id="#+id/ticket1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/ticket2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/ticket3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
<EditText
android:id="#+id/movieName"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#+id/linear1"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="10dip" />
<RelativeLayout
android:id="#+id/correctAnswerLayoutContainer"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_below="#+id/movieName"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:paddingLeft="10dip"
android:visibility="gone" >
<LinearLayout
android:id="#+id/hintContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/hintOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="musical_moview_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/hintTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="release_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/hintThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="hint3_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<Button
android:id="#+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dip"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="55dp"
android:orientation="vertical" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/publisher_id"
ads:loadAdOnCreate="true" />
</LinearLayout>
</LinearLayout>
Put the button and Adview in a new relative layout below the linear layouts.

Android how to divide half screen?

How to create layout with like this image. 50% text and rest of 50% divide by imageview textview and imageview what do i do?
please help me. I want to create screen like this image help me please.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/db1_root"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="6"
android:background="#333333" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:layout_weight="0"
android:weightSum="1.5"
android:layout_marginBottom="1dp"
android:orientation="horizontal" >
<LinearLayout
android:layout_marginRight="15dip"
android:layout_marginLeft="15dp"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:background="#drawable/layoutborder"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:layout_weight="0.8"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:paddingLeft="1dip"
android:src="#drawable/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="20dp"
android:paddingTop="5dp"
android:textSize="10dip"
android:text=CONTAINS"
android:textColor="#FFffff" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:paddingLeft="1dip"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<TextView
android:id="#+id/imageView1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:paddingLeft="1dip"
android:text="kurdfgkjdfuhfudshfkdshfdfhs
kdjhfjdshfkjdshfkdshfkshjdhfskjhfksdhfksjhfkjsdhfkjsdhfk
jshfshfshfdshdfshdkjfhsafkjsahdfksahdf" />
</LinearLayout>
</LinearLayout>
Try
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/db1_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#333333"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="1dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="1dp"
android:layout_weight="1"
android:background="#color/blue"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:paddingLeft="1dp"
android:src="#drawable/login_down" />
<TextView
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_weight="0.2"
android:paddingTop="5dp"
android:text="CONTAINS"
android:textColor="#FFffff"
android:textSize="10dip" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:paddingLeft="1dp"
android:src="#drawable/login_button" />
</LinearLayout>
<TextView
android:id="#+id/imageView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="1dp"
android:text="kurdfgkjdfuhfudshfkdshfdfhs
kdjhfjdshfkjdshfkdshfkshjdhfskjhfksdhfksjhfkjsdhfkjsdhfk
jshfshfshfdshdfshdkjfhsafkjsahdfksahdf" />
</LinearLayout>
Use as minimum layout as possible that will help in fast rendering. Try below code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/imgMainImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/txtsubImgTitle"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/textView1"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="TextView" />
<ImageView
android:id="#+id/imgSubImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/imgMainImage"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/txtsubImgTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/imgSubImg"
android:layout_alignParentLeft="true"
android:layout_marginBottom="16dp"
android:text="TextView" />
</RelativeLayout>

Move image to right

Friends I have an image and I wish to move that image to right side.Please find the necessary code below.
<?xml version="1.0" encoding="utf-8"?>
<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/imageView1"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="#drawable/error"
android:scaleType="centerCrop" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingLeft="10dp" >
<TextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/detail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000" />
<TextView
android:id="#+id/data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
I wish to move the imageView1 to the right side
Thanks in advance,for the solution
Use RelativeLayout for that and use below XML code for solve your problem.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toLeftOf="#+id/imageView1"
android:orientation="vertical"
android:paddingLeft="10dp" >
<TextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Title"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/detail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Detail"
android:textColor="#000000" />
<TextView
android:id="#+id/data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Data"
android:textColor="#000000" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentRight="true"
android:background="#drawable/error"
android:scaleType="centerCrop" />
</RelativeLayout>
check this
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:paddingLeft="10dp" >
<TextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/detail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000" />
<TextView
android:id="#+id/data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="#drawable/ic_launcher"
android:scaleType="centerCrop" />
EDIT: change ImageView background to android:background="#drawable/error"
This should work. Change second Linear layout layout_width="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:paddingLeft="10dp" >
<TextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/detail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000" />
<TextView
android:id="#+id/data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="#drawable/error"
android:scaleType="centerCrop" />
</LinearLayout>

Categories

Resources