Android : prevent edittext from hiding behind keyboard without changing manifest - android

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>

Related

Image is not fitted in webview's height

I am using an Activity having theme dialog. In that Activity's layout I have a WebView and I am loading an Image into it. But image is exceeding the height not fit properly. But I want to fit the image's height as WebView's height. I am sharing my code snippet and please tell me how can I overcome this problem.
Code snippet of Activity
myWebView.setBackgroundColor(0 * 00000000);
myWebView.getSettings().setLoadWithOverviewMode(true);
myWebView.getSettings().setUseWideViewPort(true);
myWebView.getSettings().setDisplayZoomControls(false);
myWebView.getSettings().setLoadsImagesAutomatically(true);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
myWebView.loadUrl(image1);
myWebView.refreshDrawableState();
I am giving full Xml layout
<?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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CC000000"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.56" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#000"
android:textSize="16sp"
android:textStyle="normal" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight=".27"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1.8"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="50sp"
android:layout_height="50sp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginBottom="2sp"
android:layout_marginLeft="3sp"
android:background="#drawable/load" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/imageView1"
android:text="UserName"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentRight="true"
android:layout_marginRight="10sp"
android:text="Time"
android:textColor="#fff"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rel_lay"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight=".55"
android:background="#drawable/load"
android:orientation="vertical" >
<WebView
android:id="#+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/load"
android:fadingEdge="none"
android:overScrollMode="never"
android:scrollbars="none" />
<SurfaceView
android:id="#+id/surfaceview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<RelativeLayout
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="50sp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:alpha=".9"
android:visibility="gone" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50sp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#dedcdc" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.7" >
<Button
android:id="#+id/btn_start"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginRight="5sp"
android:background="#drawable/play_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.8"
android:gravity="right" >
<TextView
android:id="#+id/txt_start_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="00.00"
android:textColor="#000"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.2" >
<SeekBar
android:id="#+id/songProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dip"
android:progressDrawable="#drawable/red_scrubber_progress"
android:thumb="#drawable/red_scrubber_control" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.8" >
<TextView
android:id="#+id/txt_end_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="00.00"
android:textColor="#000"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1.6"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:fadingEdge="none"
android:fillViewport="true"
android:overScrollMode="never" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.creepster.LinkEnabledTextView
android:id="#+id/text_caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center"
android:paddingLeft="10sp"
android:paddingRight="10sp"
android:paddingTop="8sp"
android:text=""
android:textColor="#fff"
android:textSize="12sp"
android:textStyle="normal" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1.51"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_home"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/home_black_bg"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_search"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/search"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/srcollimage"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_love"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/activity"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_me"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/me"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

Top views in scrollView are not visible in landscape screen

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

Date picker does not scroll properly inside scrollView

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>

How to resize the Dialog Box?

I would like to resize my dialogbox so for every dialog box i will have to size the full screnn size and the second use fill_parent for the size. my dilag is defined by the layout given by the code 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="#drawable/dialog_back"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:id="#+id/parcourstextV0"
style="#style/presentation_title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|left"
android:text="Parcours antérieur"
android:textColor="#color/black02"
android:textStyle="bold"
android:typeface="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="9"
android:orientation="horizontal" >
<Button
android:id="#+id/parcoursClose"
android:layout_width="40dip"
android:layout_height="40dip"
android:background="#drawable/roundedbutton"
android:text="x"
android:textColor="#color/white"
android:textSize="25dip"
android:textStyle="bold"
android:gravity="center_vertical|center"
android:typeface="normal"
android:layout_alignParentRight="true"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<ListView
android:id="#+id/listparcours"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:listSelector="#android:color/transparent" />
</LinearLayout>
</LinearLayout>
can you help me please.
// try this
<?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="#drawable/dialog_back"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/parcourstextV0"
style="#style/presentation_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|left"
android:text="Parcours antérieur"
android:textColor="#color/black02"
android:textStyle="bold"
android:typeface="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/parcoursClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roundedbutton"
android:text="x"
android:textSize="25dip"
android:textStyle="bold"
android:gravity="center"
android:typeface="normal"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ListView
android:id="#+id/listparcours"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:listSelector="#android:color/transparent" />
</LinearLayout>
</LinearLayout>

Layout xml issue in Android

Here is my layout:
Here is my XML. My layout is good except the red color part. I could not able to bring it into view. There is issue in the alignment. Is there a tool to design the layouts easily? Always facing issue in the alignments compatible to all resolutions and for both portrait and landscape dimensions.
<?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" >
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:background="#fff"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#fff"
android:orientation="vertical" >
<ImageView
android:id="#+id/productImageView"
android:layout_width="fill_parent"
android:layout_height="380dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="420dp"
android:background="#fff"
android:orientation="horizontal" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:background="#fff"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dip"
android:layout_toLeftOf="#+id/linearLayout3"
android:background="#fff"
android:orientation="vertical" >
<TextView
android:id="#+id/product_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dip"
android:layout_toLeftOf="#+id/linearLayout3"
android:background="#fff"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:layout_weight="1"
android:background="#fff"
android:orientation="horizontal" >
<TextView
android:id="#+id/your_price_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Your Price" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:layout_weight="1"
android:background="#fff"
android:orientation="horizontal" >
<TextView
android:id="#+id/your_price"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dip"
android:layout_toLeftOf="#+id/linearLayout3"
android:background="#fff"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:layout_weight="1"
android:background="#fff"
android:orientation="horizontal" >
<TextView
android:id="#+id/button4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Retail Price" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/linearLayout3"
android:layout_weight="1"
android:background="#fff"
android:orientation="horizontal" >
<TextView
android:id="#+id/retail_price"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="70dip"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/linearLayout2"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/linearLayout2"
android:background="#c0c0c0"
android:orientation="vertical" >
<ImageView
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/linearLayout15"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dip"
android:background="#c0c0c0"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="5dip"
android:background="#c0c0c0"
android:orientation="horizontal" >
<Button
android:id="#+id/button6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Buy Now" />
<Button
android:id="#+id/button7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Gush It" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout12"
android:layout_width="fill_parent"
android:layout_height="30dip"
android:layout_alignParentRight="true"
android:layout_marginTop="5dip"
android:background="#c0c0c0"
android:orientation="vertical" >
<TextView
android:id="#+id/button6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Description" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout13"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:layout_alignParentRight="true"
android:layout_marginTop="5dip"
android:background="#c0c0c0"
android:orientation="vertical" >
<TextView
android:id="#+id/product_description"
android:layout_width="fill_parent"
android:layout_height="400dp"
android:text="Button" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
If you are making a grid like this, I would prefer a GridLayout
You can set view's to specific position [+ width/height] in the GridLayout using the Spec objects in the LayoutParam

Categories

Resources