I can't see to find a way to prevent the lowest LinearLayout from being cut off within the Scroll View. I have tried adding weightsum and ensuring the Notes section (#+id/etNotes)stretches and fills the screen depending on the height of the device, however, it appears to be cutting off (#+id/bPhot) and (#+id/bHelp) How can we ensure all elements are shown even on small screens?
Any help is greatly appreciated. Thank you
<ScrollView
android:id="#+id/svMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:gravity="center_vertical">
<TextView
android:id="#+id/tvDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/yellow"
android:clickable="true"
android:padding="10dp"
android:text="TextView"
android:textSize="#dimen/seventeen" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:orientation="vertical" >
</LinearLayout>
<RadioGroup
android:id="#+id/rgStatus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="#dimen/activity_horizontal_margin" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="match_parent"
android:layout_height="46dp"
android:checked="false"
android:text="Option1"
android:textSize="#dimen/twentysize" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="Option2"
android:textSize="#dimen/twentysize" />
<RadioButton
android:id="#+id/radio2"
android:layout_width="match_parent"
android:layout_height="46dp"
android:checked="true"
android:text="Option3"
android:textSize="#dimen/twentysize" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/whitewhite"
android:weightSum="5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:background="#color/whitewhite"
android:padding="10dp" >
<EditText
android:id="#+id/etNotes"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/whitewhite"
android:ems="10"
android:gravity="top"
android:hint="Notes (optional)"
android:inputType="textMultiLine"
android:padding="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#color/whitewhite"
android:gravity="bottom"
android:orientation="horizontal"
android:padding="8dp" >
<Button
android:id="#+id/bPhoto"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_weight=".02"
android:background="#drawable/camera"
android:gravity="left|center_vertical"/>
<Button
android:id="#+id/bHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:background="#null"
android:gravity="right|center_vertical"
android:paddingRight="#dimen/sevendp"
android:text="Check List"
android:textColor="#color/holobluelight"
android:textSize="#dimen/sixteen" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Here is your complete layout revisited:
This portion has been changed:
OLD:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/whitewhite"
android:weightSum="5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:background="#color/whitewhite"
android:padding="10dp" >
<EditText
android:id="#+id/etNotes"
NEW
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/whitewhite"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/whitewhite"
android:padding="10dp" >
<EditText
android:id="#+id/etNotes"
COMPLETE
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/svMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:gravity="center_vertical">
<TextView
android:id="#+id/tvDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/yellow"
android:clickable="true"
android:padding="10dp"
android:text="TextView"
android:textSize="#dimen/seventeen" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:orientation="vertical" >
</LinearLayout>
<RadioGroup
android:id="#+id/rgStatus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="#dimen/activity_horizontal_margin" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="match_parent"
android:layout_height="46dp"
android:checked="false"
android:text="Option1"
android:textSize="#dimen/twentysize" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="Option2"
android:textSize="#dimen/twentysize" />
<RadioButton
android:id="#+id/radio2"
android:layout_width="match_parent"
android:layout_height="46dp"
android:checked="true"
android:text="Option3"
android:textSize="#dimen/twentysize" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/whitewhite"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/whitewhite"
android:padding="10dp" >
<EditText
android:id="#+id/etNotes"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/whitewhite"
android:ems="10"
android:gravity="top"
android:hint="Notes (optional)"
android:inputType="textMultiLine"
android:padding="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/whitewhite"
android:gravity="bottom"
android:orientation="horizontal"
android:padding="8dp" >
<Button
android:id="#+id/bPhoto"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_weight=".02"
android:background="#drawable/camera"
android:gravity="left|center_vertical"/>
<Button
android:id="#+id/bHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:background="#null"
android:gravity="right|center_vertical"
android:paddingRight="#dimen/sevendp"
android:text="Check List"
android:textColor="#color/holobluelight"
android:textSize="#dimen/sixteen" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Related
I have a little bit issue here.
layout which i have been designed in photoshop looks like below
and the layout which i design in xml look like below:
So, you see that for some reason, the edittexts look very off.here is the full XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1fed7b">
<LinearLayout
android:orientation="vertical"
android:gravity="center"
android:layout_weight="114"
android:layout_width="match_parent"
android:layout_height="0dp">
<ImageButton
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/txt_headline" />
</LinearLayout>
<LinearLayout
android:gravity="top"
android:orientation="horizontal"
android:layout_weight="281"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="44"
android:layout_width="0dp"
android:layout_height="match_parent" />
<LinearLayout
android:gravity="top"
android:orientation="vertical"
android:layout_weight="547"
android:layout_width="0dp"
android:layout_height="match_parent">
<ImageButton
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/txt_subline1" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="44"
android:layout_width="0dp"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="20"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="10"
android:layout_width="0dp"
android:layout_height="match_parent" />
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="10"
android:layout_width="0dp"
android:layout_height="wrap_content">
<EditText
android:id="#+id/txt_hours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:gravity="center"
android:hint="00"
android:inputType="number"
android:maxLength="2"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="55sp" />
<TextView
android:text=":"
android:layout_gravity="top"
android:gravity="center_vertical"
android:id="#+id/txt_colon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="55sp" />
<EditText
android:id="#+id/txt_minutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:gravity="center_vertical"
android:hint="00"
android:inputType="number"
android:maxLength="2"
android:singleLine="true"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="55sp" />
<LinearLayout
android:gravity="left"
android:orientation="horizontal"
android:layout_weight="10"
android:layout_width="0dp"
android:layout_height="match_parent">
<TextView
android:text="00"
android:layout_gravity="left"
android:gravity="bottom"
android:id="#+id/txt_seconds"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="189"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="160"
android:layout_width="0dp"
android:layout_height="match_parent" />
<LinearLayout
android:gravity="top"
android:orientation="vertical"
android:layout_weight="140"
android:layout_width="0dp"
android:layout_height="match_parent">
<TextView
android:text="hh"
android:layout_gravity="left"
android:gravity="top"
android:id="#+id/txt_hh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="110"
android:layout_width="0dp"
android:layout_height="match_parent" />
<LinearLayout
android:gravity="top"
android:orientation="vertical"
android:layout_weight="140"
android:layout_width="0dp"
android:layout_height="match_parent">
<TextView
android:text="mm"
android:layout_gravity="right"
android:gravity="top"
android:id="#+id/txt_mm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="160"
android:layout_width="0dp"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="250"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="314"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="314"
android:layout_width="0dp"
android:layout_height="match_parent">
<ImageButton
android:id="#+id/btn_playstore"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/btn_playstore" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="5"
android:layout_width="0dp"
android:layout_height="match_parent" />
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="314"
android:layout_width="0dp"
android:layout_height="match_parent">
<ImageButton
android:id="#+id/btn_random"
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/btn_random" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="15"
android:layout_width="match_parent"
android:layout_height="0dp" />
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="314"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="314"
android:layout_width="0dp"
android:layout_height="match_parent">
<ImageButton
android:id="#+id/btn_facebook"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/btn_fb" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="5"
android:layout_width="0dp"
android:layout_height="match_parent" />
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="314"
android:layout_width="0dp"
android:layout_height="match_parent">
<ImageButton
android:id="#+id/btn_start"
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/btn_start" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="209"
android:layout_width="match_parent"
android:layout_height="0dp">
<ImageButton
android:id="#+id/btn_skip"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/btn_skip" />
</LinearLayout>
</LinearLayout>
I know, it is a lot of code, but I really need your help here. Can you do me a favor and look through it? That be so awesome!!!
Thank you!
here is solution for your problem,copy and past code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1fed7b">
<LinearLayout
android:orientation="vertical"
android:gravity="center"
android:layout_weight="114"
android:layout_width="match_parent"
android:layout_height="0dp">
<ImageButton
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/txt_headline" />
</LinearLayout>
<LinearLayout
android:gravity="top"
android:orientation="horizontal"
android:layout_weight="281"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="44"
android:layout_width="0dp"
android:layout_height="match_parent" />
<LinearLayout
android:gravity="top"
android:orientation="vertical"
android:layout_weight="547"
android:layout_width="0dp"
android:layout_height="match_parent">
<ImageButton
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/txt_subline1" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="44"
android:layout_width="0dp"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="20"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="90dp"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/txt_hours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:hint="00"
android:inputType="number"
android:maxLength="2"
android:layout_weight="1"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="55sp" />
<TextView
android:id="#+id/txt_colon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="top"
android:gravity="center"
android:text=":"
android:layout_weight="2"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="55sp" />
<EditText
android:id="#+id/txt_minutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:layout_weight="1"
android:hint="00"
android:gravity="right"
android:inputType="number"
android:maxLength="2"
android:singleLine="true"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="55sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:orientation="horizontal">
<TextView
android:id="#+id/txt_mm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:text="mm"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="20sp" />
<TextView
android:id="#+id/txt_hh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="right"
android:text="hh"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="90dp"
android:layout_height="match_parent"
>
<TextView
android:id="#+id/txt_seconds"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="00"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="250"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="314"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="314"
android:layout_width="0dp"
android:layout_height="match_parent">
<ImageButton
android:id="#+id/btn_playstore"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/btn_playstore" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="5"
android:layout_width="0dp"
android:layout_height="match_parent" />
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="314"
android:layout_width="0dp"
android:layout_height="match_parent">
<ImageButton
android:id="#+id/btn_random"
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/btn_random" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="15"
android:layout_width="match_parent"
android:layout_height="0dp" />
<LinearLayout
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="314"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="314"
android:layout_width="0dp"
android:layout_height="match_parent">
<ImageButton
android:id="#+id/btn_facebook"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/btn_fb" />
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="5"
android:layout_width="0dp"
android:layout_height="match_parent" />
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="314"
android:layout_width="0dp"
android:layout_height="match_parent">
<ImageButton
android:id="#+id/btn_start"
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/btn_start" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:layout_weight="209"
android:layout_width="match_parent"
android:layout_height="0dp">
<ImageButton
android:id="#+id/btn_skip"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/btn_skip" />
</LinearLayout>
</LinearLayout>
hope this will solve your problem
I want to put a normal button between two layouts as showing in image.
I do not want to use floating button and coordinator layout.
Is it possible by relative layout ?
Demo Image
I am using following xml file to do it.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="10" >
<fragment
android:id="#+id/mapForPlannedRide"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="3.5" />
<LinearLayout
android:id="#+id/planned_detail_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="6.5"
android:background="#color/text_white"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:id="#+id/departure_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2.5"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/passenger" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/departure"
android:textSize="#dimen/text_size17sp" />
<TextView
android:id="#+id/departure"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="dfg ddfghd dfdg"
android:textSize="#dimen/text_size14sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".03"
android:background="#color/line_color" />
<LinearLayout
android:id="#+id/destination_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2.5"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/passenger" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/destination"
android:textSize="#dimen/text_size17sp" />
<TextView
android:id="#+id/destination"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Dilshad Garden Delhi"
android:textSize="#dimen/text_size14sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".03"
android:background="#color/line_color" />
<LinearLayout
android:id="#+id/date_time_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.5"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/passenger" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/date_time"
android:textSize="#dimen/text_size17sp" />
<TextView
android:id="#+id/date_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="10:00 a.m."
android:textSize="#dimen/text_size14sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".03"
android:background="#color/line_color" />
<LinearLayout
android:id="#+id/chosen_vehicle_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.5"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/passenger" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/chosen_vehicle"
android:textSize="#dimen/text_size17sp" />
<TextView
android:id="#+id/chosen_vehicle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Dus One"
android:textSize="#dimen/text_size14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I have tried this check below code using RelativeLayout :
<?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">
<fragment
android:id="#+id/mapForPlannedRide"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="180dp" />
<LinearLayout
android:id="#+id/departure_layout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_below="#+id/mapForPlannedRide"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/passenger" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/departure"
android:textSize="#dimen/text_size17sp" />
<TextView
android:id="#+id/departure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="dfg ddfghd dfdg"
android:textSize="#dimen/text_size14sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".03"
android:background="#color/line_color" />
<LinearLayout
android:id="#+id/destination_layout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_below="#+id/departure_layout"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/passenger" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/destination"
android:textSize="#dimen/text_size17sp" />
<TextView
android:id="#+id/destination"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Dilshad Garden Delhi"
android:textSize="#dimen/text_size14sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".03"
android:background="#color/line_color" />
<LinearLayout
android:id="#+id/date_time_layout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_below="#+id/destination_layout"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/passenger" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/date_time"
android:textSize="#dimen/text_size17sp" />
<TextView
android:id="#+id/date_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="10:00 a.m."
android:textSize="#dimen/text_size14sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".03"
android:background="#color/line_color" />
<LinearLayout
android:id="#+id/chosen_vehicle_layout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_below="#+id/date_time_layout"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/passenger" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/chosen_vehicle"
android:textSize="#dimen/text_size17sp" />
<TextView
android:id="#+id/chosen_vehicle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Dus One"
android:textSize="#dimen/text_size14sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="100dp"
android:layout_height="50"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_marginRight="20dp"
android:layout_marginTop="150dp"
android:src="#android:drawable/ic_reminder" />
</RelativeLayout>
I have coded a layout for android dialog. There is a date picker inside a scrollView. When I am trying to change the date by scrolling, it does not work properly. Date-picker gets stuck. My layout is below:
<?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"
android:padding="5dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
<TextView
android:id="#+id/text_lang_payment_method"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:text="Payment Method :"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinnerPaymentMethod"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" />
</LinearLayout>
<LinearLayout
android:id="#+id/chequeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="6" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
<TextView
android:id="#+id/text_chequeno_lang"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center_vertical"
android:text="Cheque No:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20dp" />
<EditText
android:id="#+id/inputChequeNo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/textView10"
android:layout_weight="2"
android:ems="10"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<TextView
android:id="#+id/text_Cheque_date_lang"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Cheque Date:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20dp" />
<DatePicker
android:id="#+id/dpResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:calendarViewShown="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
<TextView
android:id="#+id/text_lang_cheque_amount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center_vertical"
android:text="Cheque Amount :"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<EditText
android:id="#+id/inputChequeAmount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:inputType="numberDecimal" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
</LinearLayout>
<Button
android:id="#+id/button_add_payment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/yellobutton"
android:text="Add Payment" />
<Button
android:id="#+id/button_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/yellobutton"
android:text="Cancel" />
</LinearLayout>
How do I fix this?
Try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="5dp" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="5dp" >
<LinearLayout
android:layout_width="204dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
<TextView
android:id="#+id/text_lang_payment_method"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:text="Payment Method :"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinnerPaymentMethod"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" />
</LinearLayout>
<LinearLayout
android:id="#+id/chequeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="6" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
<TextView
android:id="#+id/text_chequeno_lang"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:text="Cheque No:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20dp" />
<EditText
android:id="#+id/inputChequeNo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:ems="10"
android:inputType="number" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<TextView
android:id="#+id/text_Cheque_date_lang"
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:gravity="center_vertical"
android:text="Cheque Date:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20dp" />
<DatePicker
android:id="#+id/dpResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:calendarViewShown="false" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
<TextView
android:id="#+id/text_lang_cheque_amount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center_vertical"
android:text="Cheque Amount :"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<EditText
android:id="#+id/inputChequeAmount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:inputType="numberDecimal" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4" >
</LinearLayout>
<Button
android:id="#+id/button_add_payment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Add Payment" />
<Button
android:id="#+id/button_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Cancel" />
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
Soft keyboard hides my edit text
this is my layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#F7F7F7"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:background="#C2C2C2"
android:orientation="horizontal"
android:weightSum="1" >
<LinearLayout
android:id="#+id/toggle1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="20dp"
android:layout_height="15dp"
android:src="#drawable/img1" />
</LinearLayout>
<LinearLayout
android:id="#+id/toggle2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="20dp"
android:layout_height="25dp"
android:src="#drawable/img2" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.65"
android:weightSum="1" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text=""
android:textColor="#000"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/list1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.15"
android:background="#EEEEEE"
android:padding="5dp"
android:weightSum="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="1" >
<EditText
android:id="#+id/addCmntTextField"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginTop="2dp"
android:layout_weight="0.8"
android:hint="Add a Comment"
android:text=""
android:textSize="11dp" />
<Button
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_marginLeft="5dp"
android:layout_weight="0.2"
android:text="Save"
android:clickable="true" />
</LinearLayout>
</LinearLayout>
in my menifest is wrote android:windowSoftInputMode="stateHidden" and i cant change it otherwise it will efect my app.How can i do it please help.
This is my complete code
Just implement a nesting in Layouts and this will solve the problem. Try doing this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="20dp"
android:gravity="bottom"
android:weightSum="1">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id=#+id/addCmntTextField"
android:layout_weight="1"
android:hint="Add a Comment"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:id="#+id/saveComment"/>
</LinearLayout>
</LinearLayout>
Here is the solution that worked for me on samsung galaxy tab
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#F7F7F7"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#C2C2C2"
android:orientation="horizontal"
android:weightSum="1" >
<LinearLayout
android:id="#+id/toggle1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="20dp"
android:layout_height="15dp"
android:src="#drawable/img1" />
</LinearLayout>
<LinearLayout
android:id="#+id/toggle2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="20dp"
android:layout_height="25dp"
android:src="#drawable/img2" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:weightSum="1" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text=""
android:textColor="#000"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/list1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="75dp"
android:background="#EEEEEE"
android:padding="5dp"
android:weightSum="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:gravity="center"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="1" >
<EditText
android:id="#+id/addCmntTextField"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginTop="2dp"
android:layout_weight="0.8"
android:hint="Add a Comment"
android:text=""
android:textSize="11dp" />
<Button
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_marginLeft="5dp"
android:layout_weight="0.2"
android:text="Save"
android:clickable="true" />
</LinearLayout>
</LinearLayout>
I want to place Image in the center and text just below it in a button, I tried to set android:gravity but could not set it properly,here is the image attached:
below is my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="10.0dip"
android:paddingTop="10.0dip"
android:paddingRight="10.0dip"
android:paddingBottom="10.0dip"
android:background="#drawable/background_img"
>
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingLeft="10.0dip"
android:paddingTop="10.0dip"
android:paddingRight="10.0dip"
android:paddingBottom="10.0dip"
>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_listen"
android:text="#string/listen"
android:drawableTop="#drawable/listen_btn"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center"
/>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_gallery"
android:text="#string/gallery"
android:drawableTop="#drawable/gallery_btn"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingLeft="10.0dip"
android:paddingTop="10.0dip"
android:paddingRight="10.0dip"
android:paddingBottom="10.0dip"
>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_play"
android:text="#string/play"
android:drawableTop="#drawable/play_btn"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
/>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_find"
android:text="#string/find"
android:drawableTop="#drawable/test_btn"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center"
/>
</LinearLayout>
</LinearLayout>
What is the proper way to center the image and text below it?
Many thanks in advance.
Try this its work for me
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="151dp"
android:onClick="onClick"
android:drawableTop="#drawable/ic_launcher"
android:text="Button" />
</RelativeLayout>
Try change the button to LinearLayout and use same onclicklistener on fakebutton
<LinearLayout
android:id="#+id/fakeButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_big_evento" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/menu_about" />
</LinearLayout>
I followed DjHacktorReborn comments and made the layout, here is the freezed one
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background_img"
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:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4.1"
android:orientation="vertical" >
</LinearLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="horizontal"
android:stretchColumns="*" >
<TableRow android:layout_weight="1" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_listen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="#drawable/main_list"
android:paddingTop="90dp"
android:text="#string/listen"
android:textStyle="bold"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/main_icon_content_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/listen_btn" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_gallery"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_list"
android:paddingTop="90dp"
android:text="#string/gallery"
android:textStyle="bold"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/main_icon_schedule_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/gallery_btn" />
</RelativeLayout>
</TableRow>
<TableRow android:layout_weight="1" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_play"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_list"
android:ellipsize="marquee"
android:paddingTop="90dp"
android:text="#string/play"
android:textStyle="bold"
android:textColor="#FFFFFF"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/play_btn" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_find"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_list"
android:paddingTop="90dp"
android:text="#string/find"
android:textStyle="bold"
android:textColor="#FFFFFF" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/test_btn" />
</RelativeLayout>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4.1"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
Here is the updated result
Thanks for the suggestions