Set a LinearLayout to scroll - android

I have been reading many posts here in stackoverflow about making a linear layout scroll and have applied all the specific advices to make it work but it still does not show on the left hand side. I am new to android and not sure what i am doing wrong.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollView1">
<LinearLayout
android:id="#+id/expense"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="start"
android:orientation="vertical"
tools:context=".Expense" >
<LinearLayout
android:id="#+id/tedsts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded"
android:clickable="true"
android:weightSum="1.0" >
<TextView
android:id="#+id/testffg"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".30"
android:text="Matter"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/tedssss"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".65"
android:ellipsize="end"
android:paddingLeft="10dp"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:src="#drawable/r_arrow" />
</LinearLayout>
<TextView
android:id="#+id/tetxttx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="0dp"
android:layout_marginRight="10dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/gray_dark"
android:visibility="invisible" />
<EditText
android:id="#+id/teetttsss"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_all"
android:ems="10"
android:gravity="top"
android:hint="dgdfgfgf"
android:inputType="textMultiLine" />
<LinearLayout
android:id="#+id/tesssstt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_all_clickable_selector"
android:clickable="true"
android:weightSum="1.0" >
<TextView
android:id="#+id/yttrree"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".20"
android:text="Date"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/rrrefffe"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".75"
android:ellipsize="end"
android:paddingLeft="10dp"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:src="#drawable/r_arrow" />
</LinearLayout>
<RadioButton
android:id="#+id/dfgrrrrr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="5dp"
android:text="Cost"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/gergrerrr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:background="#drawable/rounded_all_clickable"
android:ems="10"
android:hint=""
android:inputType="numberDecimal"
android:singleLine="true" >
</EditText>
<RadioButton
android:id="#+id/rerreee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="5dp"
android:text="Time"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/gggrrrrre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/roundede"
android:ems="10"
android:hint="grrrergg."
android:inputType="numberDecimal"
android:singleLine="true"
android:visibility="gone" >
</EditText>
<EditText
android:id="#+id/65gfhhggf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:background="#drawable/rounded"
android:ems="10"
android:hint=""
android:inputType="numberDecimal" >
</EditText>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/gfhgfhtrhrth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="50dp"
android:layout_marginTop="15dp"
android:visibility="gone" />
<TextView
android:id="#+id/ghjjhhhgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/expense_TV_total"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageButton
android:id="#+id/hgjhhghjhg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/save_selector" />
</RelativeLayout>
</LinearLayout>
</ScrollView>

use this :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView ...>
<LinearLayout ...>
...
...
</LinearLayout>
</ScrollView>
and set hieght to
android:layout_height="wrap_content"
as Karakuri said

<?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">
//Your Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="100">
// First Sub Layout Under Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="10"
android:weightSum="100" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="TextView"
android:layout_weight="70" />
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="30" />
</LinearLayout>// Finishing First Sub layout
// Second Sub Layout Under Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="10"
android:weightSum="100" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="TextView"
android:layout_weight="70" />
<EditText
android:id="#+id/editText2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="30" />
</LinearLayout>// Finishing Second Sub layout
similarly for 3rd,4rth,5th sub layouts and so on........
</LinearLayout> // Finishing Main Layout
</ScrollView> // Finishing ScrollView

Make the child of the ScrollView have android:layout_height="wrap_content" (currently yours has match_parent)

add
android:layout_width="match_parent"
android:layout_height="match_parent"
to your root ScrollView

I hope this code may be help you.
android:layout_width="match_parent"
android:layout_height="match_parent">

Related

how to add multiple frames in xml

Hi in the below xml using drawable i was added frame.Now,for single one I am displaying personal information In the same way how to display multiple but title should be different.
How do that one any one can help me.
updated
<?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" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/frame1">
<RelativeLayout
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#android:color/white">
<!-- This is the main content -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="280dp"
android:layout_margin="15dp"
android:background="#drawable/frame1"
android:orientation="vertical"
android:padding="20dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center|center_vertical"
android:background="#DFECEB"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="20dp"
android:padding="5dp"
android:text="First Name:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="15sp"
android:textStyle="bold" />
<EditText
android:id="#+id/first_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/rounded"
android:cursorVisible="true"
android:padding="5dp"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Last Name:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:textStyle="bold" />
<EditText
android:id="#+id/last_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/rounded"
android:cursorVisible="true"
android:inputType="textPassword"
android:padding="5dp"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Email:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:textStyle="bold" />
<EditText
android:id="#+id/email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/rounded"
android:cursorVisible="true"
android:inputType="textPassword"
android:padding="5dp"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="10dp"
android:padding="5dp"
android:text="Mobile No."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:textStyle="bold" />
<EditText
android:id="#+id/mobile_no"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/rounded"
android:cursorVisible="true"
android:inputType="textPassword"
android:padding="5dp"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<!-- This is the title label -->
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#android:color/white" android:padding="5dp"
android:text="Personal Information"
android:layout_marginLeft="30dp" android:textColor="#android:color/black" />
</RelativeLayout>
</FrameLayout>
</LinearLayout>
Am not 100% sure , what you are asking. If my understanding is correct, you want to wrap the frame . If so, try editing your Relative layouts height to Wrapcontent.
<RelativeLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_margin="5dp" android:background="#drawable/frame1"
android:orientation="vertical" android:padding="5dp">

How To Create Textview & Radio Button Like This

I've an application where i place Radio Button & TextView on a same line . But When i run on Nexus 7 it looks like this :
I want to create to 2nd one .How can i solve this :
Here is my XML :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#drawable/loginsigninbackground" >
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#android:color/white"
android:orientation="vertical" >
<EditText
android:id="#+id/UserNameToLogin"
android:layout_width="300dp"
android:layout_height="40dp"
android:hint="#string/username"
android:ems="10"
android:layout_gravity="center"
android:background="#drawable/customised_edit_text"
android:singleLine="true"
android:gravity="center|left"
android:textColorHint="#30D683"
android:paddingLeft="20dp"
>
<requestFocus />
</EditText>
<EditText
android:id="#+id/UserPasswordToLogin"
android:layout_width="300dp"
android:layout_height="40dp"
android:hint="#string/password"
android:ems="10"
android:inputType="textPassword"
android:layout_gravity="center"
android:background="#drawable/customised_edit_text"
android:singleLine="true"
android:gravity="center|left"
android:textColorHint="#30D683"
android:layout_marginTop="5dp"
android:paddingLeft="20dp"
>
</EditText>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/radioButtonRememberMe"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="#string/remember_me"
android:checked="false"
android:textSize="18sp"
android:textColor="#30D683"
android:button="#drawable/radio_selector"
android:background="#android:color/transparent" />
<TextView
android:id="#+id/UserRememberMe"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="#string/forgot_password"
android:textColor="#30D683"
android:textSize="18sp"
android:cacheColorHint="#android:color/transparent"
android:background="#android:color/transparent"
/>
</LinearLayout>
<Button
android:id="#+id/ButtonNext"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="#string/next"
android:background="#drawable/customised_button_click"
android:onClick="gotosignup"
android:clickable="true"
android:textSize="20sp"
/>
<Button
android:id="#+id/ButtonSignUp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/signup"
android:gravity="center"
android:textSize="20sp"
android:background="#drawable/customised_button_click"
android:onClick="gotosignup"
android:clickable="true"
/>
</LinearLayout>
</LinearLayout>
May I know what is the correct way to achieve my objective?Maybe this question too basic, but i did't find any suitable solution.Please Help me out.
Do not hardcode the height and width of your edit-text like you did
<EditText
android:id="#+id/UserPasswordToLogin"
android:layout_width="300dp"
android:layout_height="40dp"
android:hint="#string/password"
android:ems="10"
android:inputType="textPassword"
android:layout_gravity="center"
android:background="#drawable/customised_edit_text"
android:singleLine="true"
android:gravity="center|left"
android:textColorHint="#30D683"
android:layout_marginTop="5dp"
android:paddingLeft="20dp"
>
so basically it is
android:layout_width="300dp"
android:layout_height="40dp"
instead of give fill_parent or match_parent
android:layout_width="match_parent"
android:layout_height="match_parent"
or
android:layout_width="fill_parent"
android:layout_height="fill_parent"
do this for all text field and then try.
Try this..
There are two ways
1) Change EditText width as match_parent for both android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" >
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#android:color/white"
android:orientation="vertical" >
<EditText
android:id="#+id/UserNameToLogin"
android:layout_width="match_parent"
android:layout_height="40dp"
android:ems="10"
android:gravity="center|left"
android:hint="username"
android:paddingLeft="20dp"
android:singleLine="true"
android:textColorHint="#30D683" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/UserPasswordToLogin"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:ems="10"
android:gravity="center|left"
android:hint="password"
android:inputType="textPassword"
android:paddingLeft="20dp"
android:singleLine="true"
android:textColorHint="#30D683" >
</EditText>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/radioButtonRememberMe"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:checked="false"
android:text="remember_me"
android:textColor="#30D683"
android:textSize="18sp" />
<TextView
android:id="#+id/UserRememberMe"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:cacheColorHint="#android:color/transparent"
android:text="forgot_password"
android:textColor="#30D683"
android:textSize="18sp" />
</LinearLayout>
<Button
android:id="#+id/ButtonNext"
android:layout_width="match_parent"
android:layout_height="60dp"
android:clickable="true"
android:onClick="gotosignup"
android:text="next"
android:textSize="20sp" />
<Button
android:id="#+id/ButtonSignUp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="center"
android:onClick="gotosignup"
android:text="signup"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
and
2) change your LinearLayout width as 300dp and also remove android:layout_gravity="center" for both EditText
<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/radioButtonRememberMe"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="#string/remember_me"
android:checked="false"
android:textSize="18sp"
android:textColor="#30D683"
android:button="#drawable/radio_selector"
android:background="#android:color/transparent" />
<TextView
android:id="#+id/UserRememberMe"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="#string/forgot_password"
android:textColor="#30D683"
android:textSize="18sp"
android:cacheColorHint="#android:color/transparent"
android:background="#android:color/transparent"
/>
</LinearLayout>
change root linearlayout as
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
and set layout width as 300dp in childlayout
<LinearLayout
android:layout_width="300dp"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#android:color/white"
android:orientation="vertical" >

ScrollView not working in Android

ScrollView inside my layout is not working. The question might be a silly one. I already wasted an hour with it.
Here is my XML layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="1100dp"
android:layout_height="1500dp"
android:fillViewport="true"
android:background="#f7f7f7"
android:layout_weight="1"
android:orientation="vertical"
android:padding="25dp" >
<LinearLayout
android:id="#+id/container"
android:layout_width="1100dp"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="#+id/account_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:text="ACCOUNT"
android:textColor="#f44b3b"
android:textSize="18dp" />
<LinearLayout
android:layout_width="900dp"
android:layout_height="2dp"
android:layout_marginBottom="10dp"
android:background="#f44b3b" >
</LinearLayout>
<RelativeLayout
android:layout_width="1100dp"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:text="Email"
android:textColor="#333333"
android:textSize="22dp" />
<EditText
android:id="#+id/email"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_marginLeft="300dp"
android:layout_toRightOf="#+id/textView1"
android:ems="10"
android:inputType="textEmailAddress" >
</EditText>
</RelativeLayout>
<LinearLayout
android:layout_width="900dp"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#c6c6c6" >
</LinearLayout>
<RelativeLayout
android:layout_width="1100dp"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/change_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:text="Change Password"
android:textColor="#333333"
android:textSize="22dp" />
<EditText
android:id="#+id/change_password_et"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_marginLeft="170dp"
android:layout_toRightOf="#+id/change_password"
android:ems="10"
android:inputType="text" >
</EditText>
</RelativeLayout>
<LinearLayout
android:layout_width="900dp"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#c6c6c6" >
</LinearLayout>
<RelativeLayout
android:layout_width="1100dp"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/facebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:text="Facebook"
android:textColor="#333333"
android:textSize="22dp" />
<EditText
android:id="#+id/facebook_et"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_marginLeft="255dp"
android:layout_toRightOf="#+id/facebook"
android:ems="10"
android:inputType="text" >
</EditText>
</RelativeLayout>
<LinearLayout
android:layout_width="900dp"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#c6c6c6" >
</LinearLayout>
<RelativeLayout
android:layout_width="1100dp"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/twitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:text="Twitter"
android:textColor="#333333"
android:textSize="22dp" />
<EditText
android:id="#+id/twitter_et"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_marginLeft="280dp"
android:layout_toRightOf="#+id/twitter"
android:ems="10"
android:inputType="text" >
</EditText>
</RelativeLayout>
<LinearLayout
android:layout_width="900dp"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#c6c6c6" >
</LinearLayout>
<TextView
android:id="#+id/profile_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="Heading"
android:textColor="#f44b3b"
android:textSize="18dp" />
<LinearLayout
android:layout_width="900dp"
android:layout_height="2dp"
android:layout_marginBottom="10dp"
android:background="#f44b3b" >
</LinearLayout>
<RelativeLayout
android:layout_width="1100dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:id="#+id/Gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:text="Gender"
android:textColor="#333333"
android:textSize="22dp" />
<Spinner
android:id="#+id/gender_spinner"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_marginLeft="280dp"
android:layout_toRightOf="#+id/Gender" />
</RelativeLayout>
<LinearLayout
android:layout_width="900dp"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#c6c6c6" >
</LinearLayout>
<RelativeLayout
android:layout_width="1100dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:id="#+id/Birthday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="170dp"
android:text="Birthday"
android:textColor="#333333"
android:textSize="22dp" />
<Button
android:id="#+id/setDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/Birthday"
android:onClick="showDatePickerDialog"
android:text="Pick date" />
<EditText
android:id="#+id/birthdayet"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_toRightOf="#+id/Birthday"
android:ems="10"
android:inputType="text"
android:text="Birthday"
android:textColor="#f44b3b"
android:textSize="18dp" >
</EditText>
</RelativeLayout>
<LinearLayout
android:layout_width="900dp"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#c6c6c6" >
</LinearLayout>
<RelativeLayout
android:layout_width="1100dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:id="#+id/zipcode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:text="Zip Code"
android:textColor="#333333"
android:textSize="22dp" />
<EditText
android:id="#+id/zip"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_marginLeft="270dp"
android:layout_toRightOf="#+id/zipcode"
android:ems="10"
android:inputType="number" >
</EditText>
</RelativeLayout>
<LinearLayout
android:layout_width="900dp"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#c6c6c6" >
</LinearLayout>
<TextView
android:id="#+id/heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="COOL"
android:textColor="#f44b3b"
android:textSize="18dp" />
<LinearLayout
android:layout_width="900dp"
android:layout_height="2dp"
android:layout_marginBottom="8dp"
android:background="#f44b3b" >
</LinearLayout>
</LinearLayout>
</ScrollView>
Remove the
android:layout_weight="1"
android:orientation="vertical"
from the scroll view. And fill_parent the layout height..
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="1100dp"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#f7f7f7"
android:padding="25dp" >
Replaced this inside the ScrollView property
android:layout_width="fill_parent"
android:layout_height="fill_parent"
and also removed
android:layout_weight ="1"
This worked fine. Thanks to #TechEnd
Simply you have to change in Scrollview Property like as below :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#f7f7f7"
android:layout_weight="1"
android:orientation="vertical"
android:padding="25dp" >
From Manifest for this Activity Remove : "android:windowSoftInputMode="adjustPan"
It Will Work Surely.
You need to close your
< ScrollView> </ScrollView>
i don't see it or u just forget to post it ???
<ScrollView
android:layout_width="match_parent"
android:layout_height="40dp"
android:fadeScrollbars="false"
android:scrollbarStyle="insideInset"
android:scrollbarThumbVertical="#drawable/scrollview_thumb"
android:scrollbarTrackVertical="#drawable/custom_scroll_style">
<EditText
android:id="#+id/input_customer_email"
android:layout_width="match_parent"
android:layout_height="40dp"
android:clickable="false"
android:longClickable="false"
android:focusable="false"
android:inputType="textMultiLine"
android:hint="Customer's Email Address" />
</ScrollView>
In my case, the ListView will be holding an adapter for inflating a vertical stack of buttons. I've calculated and assigned the ListView height manually (in such a way that all buttons are expanded). The scrolling issue I had was, using ListView inside the ScrollView (where the scrolling happen, If I click outside the ListView's bounds and try to scroll. Whereas the scrolling won't happen, if I try to scroll by clicking inside the ListView's bounds). I went through multiple stackoverflow answers/android docs and also tried few custom ListView/LinearLayout (with adapter) but in the end nothing worked. Then, I understood the logic and made the ListView to have NestedScrolling implementation and it worked like charm.
I just made this change to my code
myListView.setNestedScrollingEnabled(true);

Setting width ratio in relative layout

Im pretty new to Android Layouts.
Im trying to set Age:EditText:Year in ratio 1:3:1 and same size on Height.
Should I use TableLayout? If yes how can i prevent TableRow1 from changing width etc when I do some stuff in other rows?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="#+id/txtAge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/search_text"
android:layout_alignBottom="#+id/search_text"
android:layout_alignParentLeft="true"
android:text="Age"
android:layout_weight="0.3"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/txtYears"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/search_text"
android:layout_alignBottom="#+id/search_text"
android:layout_alignParentRight="true"
android:text="Years"
android:layout_weight="0.3"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/search_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/txtYears"
android:layout_toRightOf="#id/txtAge"
android:ems="10"
android:hint="Enter your age"
android:inputType="text|number"
android:lines="1"
android:layout_weight="0.7"
android:maxLength="2"
android:maxLines="1" />
<TextView
android:id="#+id/txtHeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignBaseline="#+id/enterHeight"
android:layout_below="#+id/search_text"
android:text="Height"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_weight="1"/>
<Spinner
android:id="#+id/spinHeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/txtHeight"
android:layout_weight="1" />
<EditText
android:id="#+id/enterHeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/search_text"
android:layout_toLeftOf="#+id/spinHeight"
android:layout_toRightOf="#+id/txtHeight"
android:ems="10"
android:hint="Enter your height"
android:inputType="text|number"
android:lines="1"
android:layout_weight="3"
android:maxLength="3"
android:maxLines="1" >
<requestFocus />
</EditText>
</RelativeLayout>
I think this is what you want. see image 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="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical|center_horizontal"
android:text="Age"
android:textColor="#FFF"
android:textSize="16sp"
android:textStyle="bold" />
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical|center_horizontal"
android:text="Years"
android:textColor="#FFF"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical|center_horizontal"
android:text="Height"
android:textColor="#FFF"
android:textSize="16sp"
android:textStyle="bold" />
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60" />
<Spinner
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20" />
</LinearLayout>
</LinearLayout>
I think you should use linear layout.you can set android:weightSum="10" properties.
Its total layout. now you have to set for chilled object using android:layout_weight="2".
So that will control your object in layout.
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_weight="2"
android:text="Age" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="6" >
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_weight="2"
android:text="Years" />
Have something like this.. Pseudo code untested..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:gravity = "center_horizontal"
android:id="#+id/firstLinearLayout"
android:orientation = "horizontal"
android:weightSum="10">
<TextView
android:weight = "2"
/>
<TextView
android:weight = "6"
/>
<EditText
android:weight = "2"
/>
</LinearLayout>
<LinearLayout
android:gravity = "center_horizontal"
android:layout_below="#id/loginButtonLayout"
android:orientation = "horizontal"
android:weightSum="10">
</LinearLayout>

Gravity for Linear Layout

Can anyone help me in giving the gravity for four buttons developed in a vertical linear layout which is again in horizontal linear layout with progress bar. I need the whole buttons and the progress bar in the bottom of my screen. Please help me out.
Thanks in advance
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:id="#+id/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="#+id/pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/fwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:id="#+id/progressbar_Horizontal"
/>
</LinearLayout>
Hi # srinivas.
gravity for four buttons developed in a vertical linear layout which is again in horizontal
linear layout with progress bar, try out by this xml code.. its must helpful to you...
<?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="#android:color/white"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="3" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="First Name"
android:textColor="#000000" />
<EditText
android:id="#+id/firstName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="First Name"
android:maxLength="20"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="3" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Last Name"
android:textColor="#000000" />
<EditText
android:id="#+id/lastName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Last Name"
android:maxLength="20"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="3" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="UserName"
android:textColor="#000000" />
<EditText
android:id="#+id/un"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="User Name"
android:maxLength="20"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="3" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Password"
android:textColor="#000000" />
<EditText
android:id="#+id/pw"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Password"
android:maxLength="20"
android:password="true"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="3" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Email"
android:textColor="#000000" />
<EditText
android:id="#+id/email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Email"
android:maxLength="20"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="3" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Phone No."
android:textColor="#000000" />
<EditText
android:id="#+id/phoneNum"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Phone Number"
android:inputType="number"
android:maxLength="20"
android:singleLine="true"
android:textColor="#000000" >
</EditText>
</LinearLayout>
<Button
android:id="#+id/push_button"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_button"
android:text="Send Data"
android:textColor="#ffffff" />
</LinearLayout>
</ScrollView>
</LinearLayout>
android:gravity="bottom"
add this line to both your vertical as well as horizontal linear layout
I guess this was the answer you were looking for
Replace with following code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="#+id/btnLayout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/progressbar_Horizontal"
>
<Button
android:id="#+id/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="#+id/pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/fwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:id="#+id/progressbar_Horizontal"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>

Categories

Resources