view the two buttons side by side - android

I have two buttons Login and Scan. I want these buttons to be in a horizontal way just like in a single row. I tied making the layout horizontal. However it does not work. They should appear side by side. My code is as follows.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/imagesand"
android:orientation="vertical"
tools:context=".MainActivity" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/imagesand"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="207dp"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="#drawable/loginbg"
android:gravity="center"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="User Name"
android:textAppearance="#android:style/TextAppearance.Medium" />
<EditText
android:id="#+id/emailid"
android:layout_width="156dp"
android:layout_height="45dp"
android:layout_marginTop="5dp"
android:background="#drawable/button"
android:hint="User Name"
android:inputType="text"
android:paddingLeft="10dp"
android:textAppearance="#android:style/TextAppearance.Medium" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Password"
android:textAppearance="#android:style/TextAppearance.Medium" />
<EditText
android:id="#+id/password"
android:layout_width="156dp"
android:layout_height="45dp"
android:layout_marginTop="5dp"
android:background="#drawable/button"
android:hint="Password"
android:inputType="textPassword"
android:paddingLeft="10dp"
android:textAppearance="#android:style/TextAppearance.Medium" />
<Button
android:id="#+id/login"
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#drawable/login"
android:text="Login"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textColor="#000000"
android:typeface="serif" />
<Button android:id="#+id/scan"
and
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#drawable/login"
android:text="scan"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Just put both button in LinearLayout whose orientation must be horizontal

Simple use this..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:layout_weight="1"
android:text="Login"
android:textColor="#000000" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:text="Scan"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>

Use this code:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/imagesand"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="207dp"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="#drawable/loginbg"
android:gravity="center"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="User Name"
android:textAppearance="#android:style/TextAppearance.Medium" />
<EditText
android:id="#+id/emailid"
android:layout_width="156dp"
android:layout_height="45dp"
android:layout_marginTop="5dp"
android:background="#drawable/button"
android:hint="User Name"
android:inputType="text"
android:paddingLeft="10dp"
android:textAppearance="#android:style/TextAppearance.Medium" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Password"
android:textAppearance="#android:style/TextAppearance.Medium" />
<EditText
android:id="#+id/password"
android:layout_width="156dp"
android:layout_height="45dp"
android:layout_marginTop="5dp"
android:background="#drawable/button"
android:hint="Password"
android:inputType="textPassword"
android:paddingLeft="10dp"
android:textAppearance="#android:style/TextAppearance.Medium" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
<Button
android:id="#+id/login"
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#drawable/login"
android:text="Login"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textColor="#000000"
android:typeface="serif" />
<Button android:id="#+id/scan"
and
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#drawable/login"
android:text="scan"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

You can either wrap the buttons within a horizontal LinearLayout like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="#+id/login"
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#drawable/login"
android:text="Login"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textColor="#000000"
android:typeface="serif" />
<Button android:id="#+id/scan"
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#drawable/login"
android:text="scan"/>
</LinearLayout>
or use a RelativeLayout.

RealtiveLayout is the best choice:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="#+id/button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/entry"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/space"
/>
<TextView
android:id="#id/space"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"/>
<Button
android:id="#+id/button02"
android:layout_toRightOf="#id/button01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/entry"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
Seems like you want two equal buttons, not wrapped content. I created a centered spacer using TextView, and relatively aligned to that. Left button to parent left and spacer, Right button to Left Button and parent right.

This should works:
Change these,
<Button
android:id="#+id/login"
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#drawable/login"
android:text="Login"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textColor="#000000"
android:typeface="serif" />
<Button android:id="#+id/scan"
and
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#drawable/login"
android:text="scan"/>
with this,
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/login"
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#drawable/login"
android:text="Login"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textColor="#000000"
android:typeface="serif" />
<Button
android:id="#+id/scan"
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:background="#drawable/login"
android:text="scan" />
</LinearLayout>

Related

Not able to scroll my Linear Layout using ScrollView?

This is my XML file for presenting the Layout.
edit_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/login_bg">
<LinearLayout
android:id="#+id/ll_userregisteration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="30dp"
android:isScrollContainer="true"
android:gravity="center"
android:orientation="vertical">
<RelativeLayout
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<com.shout.networking.view.RoundedImageView
android:id="#+id/profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="center"
android:src="#drawable/profile_placeholder"/>
<ImageButton
android:id="#+id/camera"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="What do we call you"
android:textColor="#color/white"
android:textSize="18sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/et_reg_Fname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:textSize="16sp"
android:layout_weight="1"
android:backgroundTint="#color/white"
android:hint="first name"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<EditText
android:id="#+id/et_reg_Lname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:textSize="16sp"
android:backgroundTint="#color/white"
android:hint="last name"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
</LinearLayout>
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/rb_male"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#null"
android:checked="true"
android:drawableLeft="#drawable/selector_radio_button"
android:drawablePadding="10dp"
android:text="Male"
android:textColor="#android:color/white"
android:textSize="18sp" />
<RadioButton
android:id="#+id/rb_female"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#null"
android:checked="false"
android:drawableLeft="#drawable/selector_radio_button"
android:drawablePadding="10dp"
android:text="Female"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RadioGroup>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="School of your cool"
android:textColor="#color/white"
android:textSize="18sp" />
<EditText
android:id="#+id/et_university"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:textSize="14sp"
android:hint="add your university"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="what you call home"
android:textColor="#color/white"
android:textSize="18sp" />
<EditText
android:id="#+id/et_livingaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:hint="Where do you live now"
android:textColor="#color/white"
android:textSize="16sp"
android:textColorHint="#7c7875" />
<EditText
android:id="#+id/et_permanentaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:hint="Where do you belong to"
android:textSize="16sp"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Whats Your Calling"
android:textColor="#color/white"
android:textSize="18sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/et_interset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:layout_toLeftOf="#+id/sp_interset"
android:hint="Type in your calling/pick from the list"
android:textSize="16sp"
android:maxLength="30"
android:textColor="#color/white"
android:textColorHint="#7c7875"
android:maxLines="1" />
<Spinner
android:id="#+id/sp_interset"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:background="#drawable/down_thicker"
android:dropDownWidth="250dp"
android:backgroundTint="#android:color/white"
android:popupBackground="#4b4b49"
android:spinnerMode="dropdown" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:layout_marginTop="10dp">
<Button
android:id="#+id/btn_cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/selector_signup_button"
android:text="CANCEL"
android:layout_marginRight="20dp"
android:textColor="#color/black"
android:layout_weight="1"
android:textSize="15sp" />
<Button
android:id="#+id/btn_save"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/selector_signup_button"
android:text="SAVE"
android:textColor="#color/black"
android:layout_weight="1"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
This is the screenshot for my Layout.I am not able to scroll it.
I have put my Linear LAyout in the ScrollView but then also i am unable to get the scroll functionality in my xml design .
make changes in LinearLayout height to match_parent. it will work.
In ScrollView try adding this line:
app:layout_behavior="#string/appbar_scrolling_view_behavior"

Relative layout is shifing when progress bar running

I have login layout,when progress bar executes the layout shifts, This my xml code please check my code.And help me to rseolve.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:flatui="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:wheel="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile Number"
android:layout_marginTop="60dp"
android:layout_marginLeft="20dp"
android:textSize="15dp"
android:layout_marginBottom="40dp"
android:textStyle="bold" />
<EditText
android:id="#+id/mnum"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/edit_text_design"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="90dp"
android:layout_marginBottom="40dp"
style="#style/EditBoxStyle"
android:inputType="phone"
android:maxLength="10"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password"
android:layout_marginTop="150dp"
android:layout_marginLeft="20dp"
android:textSize="15dp"
android:layout_marginBottom="40dp"
android:textStyle="bold" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/edit_text_design"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="175dp"
android:layout_marginBottom="40dp"
style="#style/EditBoxStyle"
android:inputType="textPassword"
android:id="#+id/pswrd" />
<com.cengalabs.flatui.views.FlatButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:id="#+id/loginBtn"
android:layout_gravity="center_horizontal"
android:layout_marginTop="235dp"
flatui:fl_touchEffect="fl_ripple"
flatui:fl_theme="#array/grass"
flatui:fl_blockButtonEffectHeight="3dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="40dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/frgtext"
android:layout_gravity="center_horizontal"
android:text="Forgot Password?"
android:autoText="false"
android:clickable="true"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_marginTop="300dp"
android:textColor="#ff666666"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- <ProgressBar
android:id="#+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/loginBtn"
android:layout_centerHorizontal="true"
/>-->
<com.pnikosis.materialishprogress.ProgressWheel
android:id="#+id/loading"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
wheel:matProg_barColor="#ff5cb85c"
wheel:matProg_progressIndeterminate="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity = "bottom"
android:layout_alignParentBottom="true"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<Button
android:layout_marginLeft="-5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_weight="1"
android:id="#+id/ntregtext"
android:text="New Registration"
android:textColor="#ff666666"
android:layout_marginRight="0dp"
android:textAllCaps="false"
android:textStyle="bold" />
<Button
android:layout_marginLeft="-8dp"
android:layout_marginRight="-5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="2dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="Check our offers"
android:textColor="#ff666666"
android:textAllCaps="false"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_marginTop="50dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="5dp"
android:textAlignment="gravity"
android:textAllCaps="false"
android:textStyle="bold"
android:gravity="center_horizontal"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
Attached Images before progress bar and after progress bar running................................................
Instead of Table layout used Liner layout given weightsum as total item in horizontal.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity = "bottom"
android:layout_alignParentBottom="true"
>
<!-- <TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:layout_marginLeft="-5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_weight="1"
android:id="#+id/ntregtext"
android:text="New Registration"
android:textColor="#ff666666"
android:layout_marginRight="0dp"
android:textAllCaps="false"
android:textStyle="bold" />
<Button
android:layout_marginLeft="-8dp"
android:layout_marginRight="-5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="2dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="Check our offers"
android:textColor="#ff666666"
android:textAllCaps="false"
android:textStyle="bold" />
<!-- </TableRow>
</TableLayout>-->
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sad"
android:layout_marginTop="50dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="5dp"
android:textAlignment="gravity"
android:textAllCaps="false"
android:textStyle="bold"
android:gravity="center_horizontal"
android:layout_centerHorizontal="true" />
</RelativeLayout>

when keyboard is open layout should move above in android

I want to move my layout above when keyboard is on. I have tried with android:windowSoftInputMode="adjustPan|adjustResize". But this is not working.
When I click on EditText it should move above so that the TextView should be visible.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".EnterPin" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/top_bar"
android:padding="3dp" >
<Button
android:id="#+id/btn_home_change_pin"
android:layout_width="45dp"
android:layout_height="28dp"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:background="#drawable/grey_btn_selector"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="Home"
android:textColor="#417883"
android:textSize="11sp" />
<TextView
android:id="#+id/txt_company_name_check_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="BURBLE ME"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:paddingLeft="10dp"
android:text="Thank you for claiming your account"
android:textColor="#5DA5AE"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="9dp"
android:layout_marginLeft="5dp"
android:text="Now please enter a PIN.You will use this to allow other Burble enables Dropzones to import you."
android:textSize="14dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="18dp" >
<EditText
android:id="#+id/edt_current_pin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:background="#drawable/edittext_shape"
android:ems="10"
android:hint="Enter Pin"
android:padding="10dp"
android:textSize="14sp"
android:gravity="center_horizontal"
android:inputType="numberPassword"
android:singleLine="true" >
</EditText>
<EditText
android:id="#+id/edt_confirm_pin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:background="#drawable/edittext_shape"
android:ems="10"
android:hint="Confirm Pin"
android:padding="10dp"
android:textSize="14sp"
android:gravity="center_horizontal"
android:inputType="numberPassword"
android:singleLine="true" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="15dp"
android:weightSum="2" >
<Button
android:id="#+id/btn_pin_back"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="1"
android:background="#drawable/button_selector"
android:shadowColor="#ffffff"
android:shadowDx="1.5"
android:shadowDy="2"
android:shadowRadius="2"
android:text="Back"
android:textSize="15dp" />
<Button
android:id="#+id/btn_change_pin"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="1"
android:background="#drawable/button_selector"
android:shadowColor="#ffffff"
android:shadowDx="1.5"
android:shadowDy="2"
android:shadowRadius="2"
android:text="Next"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:text="What will I use this for?"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:text="You will use your PIN at your dropzone to manifest using their equipment and to allow a new dropzone to add you to their Burble system."
android:textSize="12dp" />
</LinearLayout>
</LinearLayout>
Add this line of code in manifest activity declaration.
<activity
android:name=".ACTIVITY NAME"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateUnchanged|adjustResize"/>
Add this lines in your AndroidManifest.xml
android:windowSoftInputMode="adjustPan"
here is your layout .
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dp" >
<Button
android:id="#+id/btn_home_change_pin"
android:layout_width="45dp"
android:layout_height="28dp"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="Home"
android:textColor="#417883"
android:textSize="11sp" />
<TextView
android:id="#+id/txt_company_name_check_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="BURBLE ME"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:paddingLeft="10dp"
android:text="Thank you for claiming your account"
android:textColor="#5DA5AE"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp"
android:layout_marginTop="9dp"
android:text="Now please enter a PIN.You will use this to allow other Burble enables Dropzones to import you."
android:textSize="14dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="18dp" >
<EditText
android:id="#+id/edt_current_pin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:ems="10"
android:gravity="center_horizontal"
android:hint="Enter Pin"
android:inputType="numberPassword"
android:padding="10dp"
android:singleLine="true"
android:textSize="14sp" >
</EditText>
<EditText
android:id="#+id/edt_confirm_pin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:ems="10"
android:gravity="center_horizontal"
android:hint="Confirm Pin"
android:inputType="numberPassword"
android:padding="10dp"
android:singleLine="true"
android:textSize="14sp" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="15dp"
android:weightSum="2" >
<Button
android:id="#+id/btn_pin_back"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="1"
android:shadowColor="#ffffff"
android:shadowDx="1.5"
android:shadowDy="2"
android:shadowRadius="2"
android:text="Back"
android:textSize="15dp" />
<Button
android:id="#+id/btn_change_pin"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="1"
android:shadowColor="#ffffff"
android:shadowDx="1.5"
android:shadowDy="2"
android:shadowRadius="2"
android:text="Next"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:text="What will I use this for?"
android:textSize="12dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:text="You will use your PIN at your dropzone to manifest using their equipment and to allow a new dropzone to add you to their Burble system."
android:textSize="12dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Add the line below to the activity this layout is inflated in. (AndroidManifest.xml) android:windowSoftInputMode="stateUnchanged|adjustPan"

Error in R.java due to an XML file

So I created this new layout in another project and it somehow corrupted it (the project). R.java shows an error on a line
public static final class id
{
**public static final int 0dp=0x7f06003b;**
public static final int AutoCompleteTextView01=0x7f060031;
The line with the asterisks gives an error:
Syntax error on token "0d", delete this token
I thought it was just a fluke so I copied my layout xml to a working project and put it there. Bam. Same error generated in that project. I want to know if there is a problem with my layout XML.
The variable names are all generic because this was just a demo design. Can the problem be caused by the 0.5dp values I'm using?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FBF2EF"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="15dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/RadioGroup01"
android:text="Pickup Address or Postcode"
android:textSize="11sp"
android:textStyle="bold"
android:layout_marginTop="40dp" />
<View
android:id="#+id/line1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginTop="0.5dp"
android:background="#000000" />
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignLeft="#+id/line1"
android:layout_alignRight="#+id/line1"
android:layout_below="#+id/line1"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Address"
android:textSize="10sp" />
<RadioButton
android:id="#+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="Postcode"
android:textSize="10sp" />
</RadioGroup>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/radioGroup"
android:layout_alignRight="#+id/radioGroup"
android:layout_below="#+id/radioGroup"
android:layout_marginTop="5dp"
android:weightSum="4.0" >
<EditText
android:id="#+id/editText1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:ems="10"
android:inputType="number"
android:text="House"
android:textSize="10sp" >
<requestFocus />
</EditText>
<AutoCompleteTextView
android:id="#+id/EditText01"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:ems="10"
android:inputType="textPostalAddress"
android:text="Street Address"
android:textSize="10sp" />
<Button
android:id="#+id/Button01"
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_weight="0.7"
android:background="#drawable/roundedbutton"
android:text="Locate"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_alignRight="#+id/linearLayout1"
android:layout_below="#+id/linearLayout1"
android:visibility="visible"
android:weightSum="4.0" >
<AutoCompleteTextView
android:id="#+id/AutoCompleteTextView01"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3.3"
android:ems="10"
android:inputType="textCapCharacters"
android:text="Enter Postcode"
android:textSize="10sp" />
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_weight="0.7"
android:background="#drawable/roundedbutton"
android:text="Search"
android:textSize="10sp" />
</LinearLayout>
<View
android:id="#+id/View01"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignLeft="#+id/TextView01"
android:layout_below="#+id/TextView01"
android:layout_marginTop="0.5dp"
android:background="#000000" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/LinearLayout01"
android:layout_below="#+id/LinearLayout01"
android:layout_marginTop="10dp"
android:text="Destination Address"
android:textSize="11sp"
android:textStyle="bold" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/View01"
android:layout_alignParentRight="true"
android:layout_below="#+id/View01"
android:layout_marginTop="5dp"
android:ems="10"
android:hint="Destination Address"
android:inputType="textPostalAddress"
android:textSize="10sp" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText2"
android:layout_below="#+id/editText2"
android:layout_marginTop="10dp"
android:text="Car Type, Passengers and Payment"
android:textSize="11sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignLeft="#+id/TextView02"
android:layout_below="#+id/TextView02"
android:layout_marginTop="5dp"
android:weightSum="3" >
<Spinner
android:id="#+id/spinner2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<View
android:id="#+id/View02"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignLeft="#+id/TextView02"
android:layout_below="#+id/TextView02"
android:layout_marginTop="0.5dp"
android:background="#000000" />
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout2"
android:layout_alignRight="#+id/linearLayout2"
android:layout_below="#+id/linearLayout2"
android:layout_marginTop="5dp"
android:weightSum="2" >
<EditText
android:id="#+id/0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="A/C Number"
android:textSize="10sp" />
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:layout_weight="1"
android:textSize="10sp" />
</LinearLayout>
<Button
android:id="#+id/button2"
android:layout_width="70dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="41dp"
android:layout_toRightOf="#+id/TextView01"
android:background="#drawable/roundedbutton"
android:text="Continue"
android:textSize="12sp" />
<TextView
android:id="#+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:text="When"
android:textSize="11sp"
android:textStyle="bold" />
<View
android:id="#+id/View03"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignLeft="#+id/TextView03"
android:layout_below="#+id/TextView03"
android:layout_marginTop="0.5dp"
android:background="#000000" />
<RadioGroup
android:id="#+id/RadioGroup01"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignLeft="#+id/View03"
android:layout_alignRight="#+id/View03"
android:layout_below="#+id/View03"
android:gravity="center"
android:orientation="horizontal"
android:layout_marginTop="5dp" >
<RadioButton
android:id="#+id/RadioButton02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Now"
android:textSize="10sp" />
<RadioButton
android:id="#+id/RadioButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="Later"
android:textSize="10sp" />
</RadioGroup>
</RelativeLayout>
</ScrollView>
Problem is with this
<EditText
android:id="#+id/0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="A/C Number"
android:textSize="10sp" />
Do this
<EditText
android:id="#+id/EditText0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="A/C Number"
android:textSize="10sp" />
Always follow naming conventions Never start any id with Numbers
After changing this You can Clean and Rebuild the project
id cannot start with a digit or a symbol except _

Button not visible at the emulator using scroll view

<?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"
>
<ScrollView
android:id="#+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<LinearLayout
android:id="#+id/MainParent"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="454dp"
android:layout_gravity="bottom"
android:layout_marginLeft="20sp"
android:layout_marginRight="20sp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80sp"
android:text="Sim Card Master"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/pumpkinorange"
android:textSize="17sp" />
<TextView
android:id="#+id/simno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:text="Sim No"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/darkblue"
android:textSize="14sp" />
<EditText
android:id="#+id/simName"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:selectAllOnFocus="true" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/TextView01"
android:layout_width="145dp"
android:layout_height="wrap_content"
android:text="Service Provider"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/darkblue"
android:textSize="14sp" />
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/service_arrays"
android:prompt="#string/serviceprovid" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100sp"
android:layout_marginTop="5dp"
android:text="Unit Master"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/pumpkinorange"
android:textSize="17sp" />
<TextView
android:id="#+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:text="Unit No"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/darkblue"
android:textSize="14sp" />
<EditText
android:id="#+id/unitNo"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:ems="10"
android:selectAllOnFocus="true" />
<TextView
android:id="#+id/TextView04"
android:layout_width="145dp"
android:layout_height="wrap_content"
android:text="IMEI No"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/darkblue"
android:textSize="14sp" />
<EditText
android:id="#+id/imeiNo"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:ems="10"
android:selectAllOnFocus="true"/>
<TextView
android:id="#+id/vehicleNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80sp"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="Vehicle Master"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/pumpkinorange"
android:textSize="17sp" />
<TextView
android:id="#+id/TextView06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Vehicle No"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/darkblue"
android:textSize="14sp" />
<EditText
android:id="#+id/vehicleNo"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:ems="10"
android:selectAllOnFocus="true"/>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:layout_gravity="center"
android:text="Save"
android:textSize="15sp"
android:textStyle="italic"
android:typeface="normal" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="Reset"
android:textSize="15sp"
android:textStyle="italic"
android:typeface="normal" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
I don't know to correct this error. In xml layout i can see the button, but in the emulator its not visible or button not scrolled. also i want this two button in same line with left and right alignment.
You Specified inside scrollview second linearlayout as
<LinearLayout
android:layout_width="match_parent"
android:layout_height="454dp"
android:layout_gravity="bottom"
android:layout_marginLeft="20sp"
android:layout_marginRight="20sp"
android:orientation="vertical" >
change to
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="20sp"
android:layout_marginRight="20sp"
android:orientation="vertical" >
You Specified height fixed that why it does't display...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="3dp"
>
<Button
android:id="#+id/login_btn"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.5"
android:text="Login"
/>
<Button
android:id="#+id/cancel_btn"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.5"
android:text="Cancel"
/>
</LinearLayout>
Set your ScrollView's height to match_parent
<ScrollView
android:id="#+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >

Categories

Resources